Skip to content

Commit

Permalink
Merge pull request #1 from microsoft/users/tedchamb/dev
Browse files Browse the repository at this point in the history
Update client methods to take a single struct arg to allow for additional args in future with no compatibility breaks.
  • Loading branch information
tedchamb authored Jul 24, 2019
2 parents dbaefad + caa3c8e commit ae52864
Show file tree
Hide file tree
Showing 54 changed files with 20,742 additions and 13,725 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Set the default behavior (used when a rule below doesn't match)
* text=auto

# Go files
*.go text eol=lf
*.mod text eol=lf
*.sum text eol=lf
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
// Get a list of all team projects
teamProjectReferences, err := coreClient.GetProjects(ctx, nil, nil, nil, nil, nil)
teamProjectReferences, err := coreClient.GetProjects(ctx, core.GetProjectsArgs{})
if err != nil {
log.Fatal(err)
}
// Print the list of team project names for your organization
for index, teamProjectReference := range *teamProjectReferences {
log.Printf("Name[%v] = %v", index, *teamProjectReference.Name)
Expand Down
28 changes: 17 additions & 11 deletions azureDevops/accounts/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,16 @@ func NewClient(ctx context.Context, connection azureDevops.Connection) (*Client,
}

// Get a list of accounts for a specific owner or a specific member.
// ctx
// ownerId (optional): ID for the owner of the accounts.
// memberId (optional): ID for a member of the accounts.
// properties (optional)
func (client Client) GetAccounts(ctx context.Context, ownerId *uuid.UUID, memberId *uuid.UUID, properties *string) (*[]Account, error) {
func (client Client) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) {
queryParams := url.Values{}
if ownerId != nil {
queryParams.Add("ownerId", (*ownerId).String())
if args.OwnerId != nil {
queryParams.Add("ownerId", (*args.OwnerId).String())
}
if memberId != nil {
queryParams.Add("memberId", (*memberId).String())
if args.MemberId != nil {
queryParams.Add("memberId", (*args.MemberId).String())
}
if properties != nil {
queryParams.Add("properties", *properties)
if args.Properties != nil {
queryParams.Add("properties", *args.Properties)
}
locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil)
Expand All @@ -59,3 +55,13 @@ func (client Client) GetAccounts(ctx context.Context, ownerId *uuid.UUID, member
return &responseValue, err
}

// Arguments for the GetAccounts function
type GetAccountsArgs struct {
// (optional) ID for the owner of the accounts.
OwnerId *uuid.UUID
// (optional) ID for a member of the accounts.
MemberId *uuid.UUID
// (optional)
Properties *string
}

Loading

0 comments on commit ae52864

Please sign in to comment.