Skip to content

Commit 7ea85c4

Browse files
authored
New updates to generated code (#99)
1 parent 33ef26a commit 7ea85c4

File tree

4 files changed

+279
-41
lines changed

4 files changed

+279
-41
lines changed

pkg/client.go

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func NewApiClient(optionFuncs ...ClientOptionFunc) (*Client, error) {
5151
return nil, fmt.Errorf("failed to create transport from GitHub App: %v", err)
5252
}
5353

54+
if options.BaseURL != "" {
55+
appTransport.BaseURL = options.BaseURL
56+
}
57+
5458
netHttpClient.Transport = appTransport
5559
}
5660

pkg/client_test.go

+49
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package pkg
22

33
import (
4+
"context"
5+
"net/http"
6+
"net/http/httptest"
47
"os"
8+
"strings"
59
"testing"
610

11+
abs "github.com/microsoft/kiota-abstractions-go"
12+
"github.com/octokit/go-sdk-enterprise-server/pkg/github/installation"
713
"github.com/octokit/go-sdk-enterprise-server/pkg/headers"
814
)
915

@@ -91,6 +97,49 @@ func TestNewApiClientAppAuthHappyPath(t *testing.T) {
9197
}
9298
}
9399

100+
func TestNewApiClientAppAuthBaseUrl(t *testing.T) {
101+
tmpfile, err := os.CreateTemp("", pemFileName)
102+
if err != nil {
103+
t.Fatal(err)
104+
}
105+
defer os.Remove(tmpfile.Name())
106+
107+
if _, err := tmpfile.Write(key); err != nil {
108+
t.Fatal(err)
109+
}
110+
if err := tmpfile.Close(); err != nil {
111+
t.Fatal(err)
112+
}
113+
114+
expectedCall := false
115+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
116+
if strings.Contains(r.URL.Path, "/app/installations") {
117+
expectedCall = true
118+
}
119+
}))
120+
121+
client, err := NewApiClient(
122+
WithGitHubAppAuthentication(tmpfile.Name(), clientID, installationID),
123+
WithBaseUrl(server.URL),
124+
)
125+
if err != nil {
126+
t.Fatalf("error creating client: %v", err)
127+
}
128+
if client == nil {
129+
t.Fatalf("client is nil")
130+
}
131+
queryParams := &installation.RepositoriesRequestBuilderGetQueryParameters{}
132+
requestConfig := &abs.RequestConfiguration[installation.RepositoriesRequestBuilderGetQueryParameters]{
133+
QueryParameters: queryParams,
134+
}
135+
136+
// trigger a refresh of the installation token to the expected url
137+
_, _ = client.Installation().Repositories().Get(context.Background(), requestConfig)
138+
if !expectedCall {
139+
t.Errorf("installation token endpoint not called")
140+
}
141+
}
142+
94143
func TestNewApiClientAppAuthErrorGettingKeyFromFile(t *testing.T) {
95144
client, err := NewApiClient(WithGitHubAppAuthentication("pem/file/does/not/exist.pem", clientID, installationID))
96145
if err == nil {

pkg/github/models/users.go

+111-41
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ import (
77
type Users struct {
88
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
99
additionalData map[string]any
10-
// Whether this email address is the primary address.
11-
primary *bool
12-
// The type of email address.
13-
typeEscaped *string
14-
// The email address.
15-
value *string
10+
// The fragment property
11+
fragment *string
12+
// The matches property
13+
matches []Users_matchesable
14+
// The object_type property
15+
object_type *string
16+
// The object_url property
17+
object_url *string
18+
// The property property
19+
property *string
1620
}
1721
// NewUsers instantiates a new Users and sets the default values.
1822
func NewUsers()(*Users) {
@@ -35,69 +39,123 @@ func (m *Users) GetAdditionalData()(map[string]any) {
3539
// returns a map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error) when successful
3640
func (m *Users) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) {
3741
res := make(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error))
38-
res["primary"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
39-
val, err := n.GetBoolValue()
42+
res["fragment"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
43+
val, err := n.GetStringValue()
44+
if err != nil {
45+
return err
46+
}
47+
if val != nil {
48+
m.SetFragment(val)
49+
}
50+
return nil
51+
}
52+
res["matches"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
53+
val, err := n.GetCollectionOfObjectValues(CreateUsers_matchesFromDiscriminatorValue)
54+
if err != nil {
55+
return err
56+
}
57+
if val != nil {
58+
res := make([]Users_matchesable, len(val))
59+
for i, v := range val {
60+
if v != nil {
61+
res[i] = v.(Users_matchesable)
62+
}
63+
}
64+
m.SetMatches(res)
65+
}
66+
return nil
67+
}
68+
res["object_type"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
69+
val, err := n.GetStringValue()
4070
if err != nil {
4171
return err
4272
}
4373
if val != nil {
44-
m.SetPrimary(val)
74+
m.SetObjectType(val)
4575
}
4676
return nil
4777
}
48-
res["type"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
78+
res["object_url"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
4979
val, err := n.GetStringValue()
5080
if err != nil {
5181
return err
5282
}
5383
if val != nil {
54-
m.SetTypeEscaped(val)
84+
m.SetObjectUrl(val)
5585
}
5686
return nil
5787
}
58-
res["value"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
88+
res["property"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
5989
val, err := n.GetStringValue()
6090
if err != nil {
6191
return err
6292
}
6393
if val != nil {
64-
m.SetValue(val)
94+
m.SetProperty(val)
6595
}
6696
return nil
6797
}
6898
return res
6999
}
70-
// GetPrimary gets the primary property value. Whether this email address is the primary address.
71-
// returns a *bool when successful
72-
func (m *Users) GetPrimary()(*bool) {
73-
return m.primary
100+
// GetFragment gets the fragment property value. The fragment property
101+
// returns a *string when successful
102+
func (m *Users) GetFragment()(*string) {
103+
return m.fragment
104+
}
105+
// GetMatches gets the matches property value. The matches property
106+
// returns a []Users_matchesable when successful
107+
func (m *Users) GetMatches()([]Users_matchesable) {
108+
return m.matches
109+
}
110+
// GetObjectType gets the object_type property value. The object_type property
111+
// returns a *string when successful
112+
func (m *Users) GetObjectType()(*string) {
113+
return m.object_type
74114
}
75-
// GetTypeEscaped gets the type property value. The type of email address.
115+
// GetObjectUrl gets the object_url property value. The object_url property
76116
// returns a *string when successful
77-
func (m *Users) GetTypeEscaped()(*string) {
78-
return m.typeEscaped
117+
func (m *Users) GetObjectUrl()(*string) {
118+
return m.object_url
79119
}
80-
// GetValue gets the value property value. The email address.
120+
// GetProperty gets the property property value. The property property
81121
// returns a *string when successful
82-
func (m *Users) GetValue()(*string) {
83-
return m.value
122+
func (m *Users) GetProperty()(*string) {
123+
return m.property
84124
}
85125
// Serialize serializes information the current object
86126
func (m *Users) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {
87127
{
88-
err := writer.WriteBoolValue("primary", m.GetPrimary())
128+
err := writer.WriteStringValue("fragment", m.GetFragment())
129+
if err != nil {
130+
return err
131+
}
132+
}
133+
if m.GetMatches() != nil {
134+
cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetMatches()))
135+
for i, v := range m.GetMatches() {
136+
if v != nil {
137+
cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)
138+
}
139+
}
140+
err := writer.WriteCollectionOfObjectValues("matches", cast)
141+
if err != nil {
142+
return err
143+
}
144+
}
145+
{
146+
err := writer.WriteStringValue("object_type", m.GetObjectType())
89147
if err != nil {
90148
return err
91149
}
92150
}
93151
{
94-
err := writer.WriteStringValue("type", m.GetTypeEscaped())
152+
err := writer.WriteStringValue("object_url", m.GetObjectUrl())
95153
if err != nil {
96154
return err
97155
}
98156
}
99157
{
100-
err := writer.WriteStringValue("value", m.GetValue())
158+
err := writer.WriteStringValue("property", m.GetProperty())
101159
if err != nil {
102160
return err
103161
}
@@ -114,25 +172,37 @@ func (m *Users) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c4
114172
func (m *Users) SetAdditionalData(value map[string]any)() {
115173
m.additionalData = value
116174
}
117-
// SetPrimary sets the primary property value. Whether this email address is the primary address.
118-
func (m *Users) SetPrimary(value *bool)() {
119-
m.primary = value
175+
// SetFragment sets the fragment property value. The fragment property
176+
func (m *Users) SetFragment(value *string)() {
177+
m.fragment = value
178+
}
179+
// SetMatches sets the matches property value. The matches property
180+
func (m *Users) SetMatches(value []Users_matchesable)() {
181+
m.matches = value
182+
}
183+
// SetObjectType sets the object_type property value. The object_type property
184+
func (m *Users) SetObjectType(value *string)() {
185+
m.object_type = value
120186
}
121-
// SetTypeEscaped sets the type property value. The type of email address.
122-
func (m *Users) SetTypeEscaped(value *string)() {
123-
m.typeEscaped = value
187+
// SetObjectUrl sets the object_url property value. The object_url property
188+
func (m *Users) SetObjectUrl(value *string)() {
189+
m.object_url = value
124190
}
125-
// SetValue sets the value property value. The email address.
126-
func (m *Users) SetValue(value *string)() {
127-
m.value = value
191+
// SetProperty sets the property property value. The property property
192+
func (m *Users) SetProperty(value *string)() {
193+
m.property = value
128194
}
129195
type Usersable interface {
130196
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.AdditionalDataHolder
131197
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable
132-
GetPrimary()(*bool)
133-
GetTypeEscaped()(*string)
134-
GetValue()(*string)
135-
SetPrimary(value *bool)()
136-
SetTypeEscaped(value *string)()
137-
SetValue(value *string)()
198+
GetFragment()(*string)
199+
GetMatches()([]Users_matchesable)
200+
GetObjectType()(*string)
201+
GetObjectUrl()(*string)
202+
GetProperty()(*string)
203+
SetFragment(value *string)()
204+
SetMatches(value []Users_matchesable)()
205+
SetObjectType(value *string)()
206+
SetObjectUrl(value *string)()
207+
SetProperty(value *string)()
138208
}

0 commit comments

Comments
 (0)