Skip to content

Commit 0f6c21f

Browse files
committed
Update client methods to take a single struct arg to allow for additional args in future with no compatability breaks.
1 parent dbaefad commit 0f6c21f

File tree

54 files changed

+20760
-13743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+20760
-13743
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Set the default behavior (used when a rule below doesn't match)
22
* text=auto
33

4+
# Go files
45
*.go text eol=lf
56
*.mod text eol=lf
67
*.sum text eol=lf

README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@ func main() {
1818
organizationUrl := "https://dev.azure.com/myorg" // todo: replace value with your organization url
1919
personalAccessToken := "XXXXXXXXXXXXXXXXXXXXXXX" // todo: replace value with your PAT
2020
21-
// Create a connection to your organization
22-
connection := azureDevops.NewConnection(organizationUrl, personalAccessToken)
23-
24-
ctx := context.Background()
25-
26-
// Create a client to interact with the Core area
27-
coreClient, err := core.NewClient(ctx, *connection)
28-
if err != nil {
29-
log.Fatal(err)
30-
}
31-
32-
// Get a list of all team projects
33-
teamProjectReferences, err := coreClient.GetProjects(ctx, nil, nil, nil, nil, nil)
34-
if err != nil {
35-
log.Fatal(err)
36-
}
37-
38-
// Print the list of team project names for your organization
39-
for index, teamProjectReference := range *teamProjectReferences {
40-
log.Printf("Name[%v] = %v", index, *teamProjectReference.Name)
41-
}
21+
// Create a connection to your organization
22+
connection := azureDevops.NewConnection(organizationUrl, personalAccessToken)
23+
24+
ctx := context.Background()
25+
26+
// Create a client to interact with the Core area
27+
coreClient, err := core.NewClient(ctx, *connection)
28+
if err != nil {
29+
log.Fatal(err)
30+
}
31+
32+
// Get a list of all team projects
33+
teamProjectReferences, err := coreClient.GetProjects(ctx, core.GetProjectsArgs{})
34+
if err != nil {
35+
log.Fatal(err)
36+
}
37+
38+
// Print the list of team project names for your organization
39+
for index, teamProjectReference := range *teamProjectReferences {
40+
log.Printf("Name[%v] = %v", index, *teamProjectReference.Name)
41+
}
4242
}
4343
```
4444

azureDevops/accounts/client.go

+17-11
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,16 @@ func NewClient(ctx context.Context, connection azureDevops.Connection) (*Client,
3333
}
3434

3535
// Get a list of accounts for a specific owner or a specific member.
36-
// ctx
37-
// ownerId (optional): ID for the owner of the accounts.
38-
// memberId (optional): ID for a member of the accounts.
39-
// properties (optional)
40-
func (client Client) GetAccounts(ctx context.Context, ownerId *uuid.UUID, memberId *uuid.UUID, properties *string) (*[]Account, error) {
36+
func (client Client) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) {
4137
queryParams := url.Values{}
42-
if ownerId != nil {
43-
queryParams.Add("ownerId", (*ownerId).String())
38+
if args.OwnerId != nil {
39+
queryParams.Add("ownerId", (*args.OwnerId).String())
4440
}
45-
if memberId != nil {
46-
queryParams.Add("memberId", (*memberId).String())
41+
if args.MemberId != nil {
42+
queryParams.Add("memberId", (*args.MemberId).String())
4743
}
48-
if properties != nil {
49-
queryParams.Add("properties", *properties)
44+
if args.Properties != nil {
45+
queryParams.Add("properties", *args.Properties)
5046
}
5147
locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e")
5248
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil)
@@ -59,3 +55,13 @@ func (client Client) GetAccounts(ctx context.Context, ownerId *uuid.UUID, member
5955
return &responseValue, err
6056
}
6157

58+
// Arguments for the GetAccounts function
59+
type GetAccountsArgs struct {
60+
// (optional) ID for the owner of the accounts.
61+
OwnerId *uuid.UUID
62+
// (optional) ID for a member of the accounts.
63+
MemberId *uuid.UUID
64+
// (optional)
65+
Properties *string
66+
}
67+

0 commit comments

Comments
 (0)