Skip to content

Commit

Permalink
Fix issue with oddball route templates (CreateWorkItem). Get rid of u…
Browse files Browse the repository at this point in the history
…nderscores at end of parameter names that match keyword since args are now a single struct. (#15)

* Fix issue with oddball route templates (CreateWorkItem).  Get rid of underscores at end of parameter names that match keyword since args are now a single struct.

* fix arg name in argnilerrors
  • Loading branch information
tedchamb authored Aug 13, 2019
1 parent 7260105 commit d4b6892
Show file tree
Hide file tree
Showing 54 changed files with 2,369 additions and 2,332 deletions.
348 changes: 174 additions & 174 deletions azuredevops/build/client.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions azuredevops/cix/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewClient(ctx context.Context, connection *azuredevops.Connection) *Client
func (client *Client) GetConfigurations(ctx context.Context, args GetConfigurationsArgs) (*[]ConfigurationFile, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "project"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project

Expand Down Expand Up @@ -78,7 +78,7 @@ type GetConfigurationsArgs struct {
// [Preview API] Creates a new Pipeline connection between the provider installation and the specified project. Returns the PipelineConnection object created.
func (client *Client) CreateProjectConnection(ctx context.Context, args CreateProjectConnectionArgs) (*PipelineConnection, error) {
if args.CreateConnectionInputs == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "createConnectionInputs"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreateConnectionInputs"}
}
queryParams := url.Values{}
if args.Project == nil {
Expand Down Expand Up @@ -112,7 +112,7 @@ type CreateProjectConnectionArgs struct {
func (client *Client) GetDetectedBuildFrameworks(ctx context.Context, args GetDetectedBuildFrameworksArgs) (*[]DetectedBuildFramework, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "project"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project

Expand Down Expand Up @@ -163,7 +163,7 @@ type GetDetectedBuildFrameworksArgs struct {
func (client *Client) GetTemplateRecommendations(ctx context.Context, args GetTemplateRecommendationsArgs) (*[]Template, error) {
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "project"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project

Expand Down Expand Up @@ -208,11 +208,11 @@ type GetTemplateRecommendationsArgs struct {
// [Preview API]
func (client *Client) CreateResources(ctx context.Context, args CreateResourcesArgs) (*CreatedResources, error) {
if args.CreationParameters == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "creationParameters"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreationParameters"}
}
routeValues := make(map[string]string)
if args.Project == nil || *args.Project == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "project"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"}
}
routeValues["project"] = *args.Project

Expand Down Expand Up @@ -242,11 +242,11 @@ type CreateResourcesArgs struct {
// [Preview API]
func (client *Client) RenderTemplate(ctx context.Context, args RenderTemplateArgs) (*Template, error) {
if args.TemplateParameters == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "templateParameters"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TemplateParameters"}
}
routeValues := make(map[string]string)
if args.TemplateId == nil || *args.TemplateId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "templateId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TemplateId"}
}
routeValues["templateId"] = *args.TemplateId

Expand Down
5 changes: 5 additions & 0 deletions azuredevops/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,13 @@ func transformRouteTemplate(routeTemplate string, routeValues map[string]string)
if ok {
newTemplate += "/" + url.PathEscape(value)
}
// else this is an optional parameter that has not been supplied, so don't add it back
}
}
// following covers oddball templates with segments that include the token and additional constants
for key, value := range routeValues {
newTemplate = strings.Replace(newTemplate, "{"+key+"}", value, -1)
}
return newTemplate
}

Expand Down
2 changes: 1 addition & 1 deletion azuredevops/clientTrace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewClient(ctx context.Context, connection *azuredevops.Connection) *Client
// [Preview API]
func (client *Client) PublishEvents(ctx context.Context, args PublishEventsArgs) error {
if args.Events == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "events"}
return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"}
}
body, marshalErr := json.Marshal(*args.Events)
if marshalErr != nil {
Expand Down
58 changes: 29 additions & 29 deletions azuredevops/cloudloadtest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewClient(ctx context.Context, connection *azuredevops.Connection) (*Client

func (client *Client) CreateAgentGroup(ctx context.Context, args CreateAgentGroupArgs) (*testservice.AgentGroup, error) {
if args.Group == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "group"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"}
}
body, marshalErr := json.Marshal(*args.Group)
if marshalErr != nil {
Expand Down Expand Up @@ -108,7 +108,7 @@ type GetAgentGroupsArgs struct {
func (client *Client) DeleteStaticAgent(ctx context.Context, args DeleteStaticAgentArgs) (*string, error) {
routeValues := make(map[string]string)
if args.AgentGroupId == nil || *args.AgentGroupId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "agentGroupId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AgentGroupId"}
}
routeValues["agentGroupId"] = *args.AgentGroupId

Expand Down Expand Up @@ -139,7 +139,7 @@ type DeleteStaticAgentArgs struct {
func (client *Client) GetStaticAgents(ctx context.Context, args GetStaticAgentsArgs) (interface{}, error) {
routeValues := make(map[string]string)
if args.AgentGroupId == nil || *args.AgentGroupId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "agentGroupId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AgentGroupId"}
}
routeValues["agentGroupId"] = *args.AgentGroupId

Expand Down Expand Up @@ -169,7 +169,7 @@ type GetStaticAgentsArgs struct {
func (client *Client) GetApplication(ctx context.Context, args GetApplicationArgs) (*testservice.Application, error) {
routeValues := make(map[string]string)
if args.ApplicationId == nil || *args.ApplicationId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "applicationId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ApplicationId"}
}
routeValues["applicationId"] = *args.ApplicationId

Expand All @@ -192,8 +192,8 @@ type GetApplicationArgs struct {

func (client *Client) GetApplications(ctx context.Context, args GetApplicationsArgs) (*[]testservice.Application, error) {
queryParams := url.Values{}
if args.Type_ != nil {
queryParams.Add("type_", *args.Type_)
if args.Type != nil {
queryParams.Add("type", *args.Type)
}
locationId, _ := uuid.Parse("2c986dce-8e8d-4142-b541-d016d5aff764")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil)
Expand All @@ -209,13 +209,13 @@ func (client *Client) GetApplications(ctx context.Context, args GetApplicationsA
// Arguments for the GetApplications function
type GetApplicationsArgs struct {
// (optional) Filters the results based on the plugin type.
Type_ *string
Type *string
}

func (client *Client) GetCounters(ctx context.Context, args GetCountersArgs) (*[]testservice.TestRunCounterInstance, error) {
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

Expand Down Expand Up @@ -277,11 +277,11 @@ type GetApplicationCountersArgs struct {

func (client *Client) GetCounterSamples(ctx context.Context, args GetCounterSamplesArgs) (*testservice.CounterSamplesResult, error) {
if args.CounterSampleQueryDetails == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "counterSampleQueryDetails"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CounterSampleQueryDetails"}
}
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

Expand Down Expand Up @@ -311,13 +311,13 @@ type GetCounterSamplesArgs struct {
func (client *Client) GetLoadTestRunErrors(ctx context.Context, args GetLoadTestRunErrorsArgs) (*testservice.LoadTestErrors, error) {
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

queryParams := url.Values{}
if args.Type_ != nil {
queryParams.Add("type_", *args.Type_)
if args.Type != nil {
queryParams.Add("type", *args.Type)
}
if args.SubType != nil {
queryParams.Add("subType", *args.SubType)
Expand All @@ -341,7 +341,7 @@ type GetLoadTestRunErrorsArgs struct {
// (required) The test run identifier
TestRunId *string
// (optional) Filter for the particular type of errors.
Type_ *string
Type *string
// (optional) Filter for a particular subtype of errors. You should not provide error subtype without error type.
SubType *string
// (optional) To include the details of test errors such as messagetext, request, stacktrace, testcasename, scenarioname, and lasterrordate.
Expand All @@ -351,7 +351,7 @@ type GetLoadTestRunErrorsArgs struct {
func (client *Client) GetTestRunMessages(ctx context.Context, args GetTestRunMessagesArgs) (*[]testservice.TestRunMessage, error) {
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

Expand All @@ -374,10 +374,10 @@ type GetTestRunMessagesArgs struct {

func (client *Client) GetPlugin(ctx context.Context, args GetPluginArgs) (*testservice.ApplicationType, error) {
routeValues := make(map[string]string)
if args.Type_ == nil || *args.Type_ == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "type_"}
if args.Type == nil || *args.Type == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"}
}
routeValues["type_"] = *args.Type_
routeValues["type"] = *args.Type

locationId, _ := uuid.Parse("7dcb0bb2-42d5-4729-9958-c0401d5e7693")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil)
Expand All @@ -393,7 +393,7 @@ func (client *Client) GetPlugin(ctx context.Context, args GetPluginArgs) (*tests
// Arguments for the GetPlugin function
type GetPluginArgs struct {
// (required) Currently ApplicationInsights is the only available plugin type.
Type_ *string
Type *string
}

func (client *Client) GetPlugins(ctx context.Context, args GetPluginsArgs) (*[]testservice.ApplicationType, error) {
Expand All @@ -415,7 +415,7 @@ type GetPluginsArgs struct {
func (client *Client) GetLoadTestResult(ctx context.Context, args GetLoadTestResultArgs) (*testservice.TestResults, error) {
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

Expand All @@ -438,7 +438,7 @@ type GetLoadTestResultArgs struct {

func (client *Client) CreateTestDefinition(ctx context.Context, args CreateTestDefinitionArgs) (*testservice.TestDefinition, error) {
if args.TestDefinition == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "testDefinition"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestDefinition"}
}
body, marshalErr := json.Marshal(*args.TestDefinition)
if marshalErr != nil {
Expand All @@ -464,7 +464,7 @@ type CreateTestDefinitionArgs struct {
func (client *Client) GetTestDefinition(ctx context.Context, args GetTestDefinitionArgs) (*testservice.TestDefinition, error) {
routeValues := make(map[string]string)
if args.TestDefinitionId == nil || *args.TestDefinitionId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testDefinitionId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestDefinitionId"}
}
routeValues["testDefinitionId"] = *args.TestDefinitionId

Expand Down Expand Up @@ -519,7 +519,7 @@ type GetTestDefinitionsArgs struct {

func (client *Client) UpdateTestDefinition(ctx context.Context, args UpdateTestDefinitionArgs) (*testservice.TestDefinition, error) {
if args.TestDefinition == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "testDefinition"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestDefinition"}
}
body, marshalErr := json.Marshal(*args.TestDefinition)
if marshalErr != nil {
Expand All @@ -544,7 +544,7 @@ type UpdateTestDefinitionArgs struct {

func (client *Client) CreateTestDrop(ctx context.Context, args CreateTestDropArgs) (*testservice.TestDrop, error) {
if args.WebTestDrop == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "webTestDrop"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WebTestDrop"}
}
body, marshalErr := json.Marshal(*args.WebTestDrop)
if marshalErr != nil {
Expand All @@ -570,7 +570,7 @@ type CreateTestDropArgs struct {
func (client *Client) GetTestDrop(ctx context.Context, args GetTestDropArgs) (*testservice.TestDrop, error) {
routeValues := make(map[string]string)
if args.TestDropId == nil || *args.TestDropId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testDropId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestDropId"}
}
routeValues["testDropId"] = *args.TestDropId

Expand All @@ -593,7 +593,7 @@ type GetTestDropArgs struct {

func (client *Client) CreateTestRun(ctx context.Context, args CreateTestRunArgs) (*testservice.TestRun, error) {
if args.WebTestRun == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "webTestRun"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WebTestRun"}
}
body, marshalErr := json.Marshal(*args.WebTestRun)
if marshalErr != nil {
Expand All @@ -619,7 +619,7 @@ type CreateTestRunArgs struct {
func (client *Client) GetTestRun(ctx context.Context, args GetTestRunArgs) (*testservice.TestRun, error) {
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

Expand Down Expand Up @@ -710,11 +710,11 @@ type GetTestRunsArgs struct {

func (client *Client) UpdateTestRun(ctx context.Context, args UpdateTestRunArgs) error {
if args.WebTestRun == nil {
return &azuredevops.ArgumentNilError{ArgumentName: "webTestRun"}
return &azuredevops.ArgumentNilError{ArgumentName: "args.WebTestRun"}
}
routeValues := make(map[string]string)
if args.TestRunId == nil || *args.TestRunId == "" {
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "testRunId"}
return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"}
}
routeValues["testRunId"] = *args.TestRunId

Expand Down
8 changes: 4 additions & 4 deletions azuredevops/contributions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewClient(ctx context.Context, connection *azuredevops.Connection) (*Client
// [Preview API] Query for contribution nodes and provider details according the parameters in the passed in query object.
func (client *Client) QueryContributionNodes(ctx context.Context, args QueryContributionNodesArgs) (*ContributionNodeQueryResult, error) {
if args.Query == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "query"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"}
}
body, marshalErr := json.Marshal(*args.Query)
if marshalErr != nil {
Expand All @@ -65,7 +65,7 @@ type QueryContributionNodesArgs struct {
// [Preview API]
func (client *Client) QueryDataProviders(ctx context.Context, args QueryDataProvidersArgs) (*DataProviderResult, error) {
if args.Query == nil {
return nil, &azuredevops.ArgumentNilError{ArgumentName: "query"}
return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"}
}
routeValues := make(map[string]string)
if args.ScopeName != nil && *args.ScopeName != "" {
Expand Down Expand Up @@ -139,11 +139,11 @@ type GetInstalledExtensionsArgs struct {
func (client *Client) GetInstalledExtensionByName(ctx context.Context, args GetInstalledExtensionByNameArgs) (*InstalledExtension, error) {
routeValues := make(map[string]string)
if args.PublisherName == nil || *args.PublisherName == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "publisherName"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"}
}
routeValues["publisherName"] = *args.PublisherName
if args.ExtensionName == nil || *args.ExtensionName == "" {
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "extensionName"}
return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"}
}
routeValues["extensionName"] = *args.ExtensionName

Expand Down
Loading

0 comments on commit d4b6892

Please sign in to comment.