From 39f7db1cf12b4bc7fa59a7f616b95a52d989887e Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 19 Sep 2018 21:28:12 -0700 Subject: [PATCH] Generated from 9a606876823b5c16373b7460dd47a2256aacd86c (#2771) Fix ARMViolations for Microsoft.Solutions --- .../mgmt/managedapplications/models.go | 5 + .../managedapplications/appliances.go | 8 +- .../managedapplications/client.go | 89 +++++++++++++ .../managedapplications/models.go | 121 ++++++++++++++++++ 4 files changed, 219 insertions(+), 4 deletions(-) diff --git a/profiles/preview/preview/resources/mgmt/managedapplications/models.go b/profiles/preview/preview/resources/mgmt/managedapplications/models.go index c0e22a53d7b2..9406f6cf46fa 100644 --- a/profiles/preview/preview/resources/mgmt/managedapplications/models.go +++ b/profiles/preview/preview/resources/mgmt/managedapplications/models.go @@ -91,6 +91,11 @@ type AppliancesDeleteFuture = original.AppliancesDeleteFuture type ErrorResponse = original.ErrorResponse type GenericResource = original.GenericResource type Identity = original.Identity +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationListResultIterator = original.OperationListResultIterator +type OperationListResultPage = original.OperationListResultPage type Plan = original.Plan type PlanPatchable = original.PlanPatchable type Resource = original.Resource diff --git a/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/appliances.go b/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/appliances.go index a1a6b7a5e284..c599b7fc219a 100644 --- a/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/appliances.go +++ b/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/appliances.go @@ -55,7 +55,7 @@ func (client AppliancesClient) CreateOrUpdate(ctx context.Context, resourceGroup Constraints: []validation.Constraint{{Target: "applianceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, {Target: "applianceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ApplianceProperties", Name: validation.Null, Rule: true, + Constraints: []validation.Constraint{{Target: "parameters.ApplianceProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ApplianceProperties.ManagedResourceGroupID", Name: validation.Null, Rule: true, Chain: nil}}}, {Target: "parameters.Plan", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil}, @@ -63,7 +63,7 @@ func (client AppliancesClient) CreateOrUpdate(ctx context.Context, resourceGroup {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil}, }}, - {Target: "parameters.Kind", Name: validation.Null, Rule: true, + {Target: "parameters.Kind", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { return result, validation.NewError("managedapplications.AppliancesClient", "CreateOrUpdate", err.Error()) } @@ -145,7 +145,7 @@ func (client AppliancesClient) CreateOrUpdateResponder(resp *http.Response) (res func (client AppliancesClient) CreateOrUpdateByID(ctx context.Context, applianceID string, parameters Appliance) (result AppliancesCreateOrUpdateByIDFuture, err error) { if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ApplianceProperties", Name: validation.Null, Rule: true, + Constraints: []validation.Constraint{{Target: "parameters.ApplianceProperties", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ApplianceProperties.ManagedResourceGroupID", Name: validation.Null, Rule: true, Chain: nil}}}, {Target: "parameters.Plan", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil}, @@ -153,7 +153,7 @@ func (client AppliancesClient) CreateOrUpdateByID(ctx context.Context, appliance {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil}, }}, - {Target: "parameters.Kind", Name: validation.Null, Rule: true, + {Target: "parameters.Kind", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { return result, validation.NewError("managedapplications.AppliancesClient", "CreateOrUpdateByID", err.Error()) } diff --git a/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/client.go b/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/client.go index cf1888cf5acf..0489804f7441 100644 --- a/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/client.go +++ b/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/client.go @@ -21,7 +21,10 @@ package managedapplications // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( + "context" "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" ) const ( @@ -49,3 +52,89 @@ func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { SubscriptionID: subscriptionID, } } + +// ListOperations lists all of the available Microsoft.Solutions REST API operations. +func (client BaseClient) ListOperations(ctx context.Context) (result OperationListResultPage, err error) { + result.fn = client.listOperationsNextResults + req, err := client.ListOperationsPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "ListOperations", nil, "Failure preparing request") + return + } + + resp, err := client.ListOperationsSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "ListOperations", resp, "Failure sending request") + return + } + + result.olr, err = client.ListOperationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "ListOperations", resp, "Failure responding to request") + } + + return +} + +// ListOperationsPreparer prepares the ListOperations request. +func (client BaseClient) ListOperationsPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Solutions/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListOperationsSender sends the ListOperations request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) ListOperationsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListOperationsResponder handles the response to the ListOperations request. The method always +// closes the http.Response Body. +func (client BaseClient) ListOperationsResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listOperationsNextResults retrieves the next set of results, if any. +func (client BaseClient) listOperationsNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.BaseClient", "listOperationsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListOperationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.BaseClient", "listOperationsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListOperationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.BaseClient", "listOperationsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListOperationsComplete enumerates all values, automatically crossing page boundaries as required. +func (client BaseClient) ListOperationsComplete(ctx context.Context) (result OperationListResultIterator, err error) { + result.page, err = client.ListOperations(ctx) + return +} diff --git a/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/models.go b/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/models.go index 771802c6b778..e0b2d8baa80b 100644 --- a/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/models.go +++ b/services/preview/resources/mgmt/2016-09-01-preview/managedapplications/models.go @@ -1161,6 +1161,127 @@ type Identity struct { Type ResourceIdentityType `json:"type,omitempty"` } +// Operation microsoft.Solutions operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.Solutions + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list Microsoft.Solutions operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of Microsoft.Solutions operations. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + // Plan plan for the appliance. type Plan struct { // Name - The plan name.