diff --git a/services/analysisservices/mgmt/2017-07-14/analysisservices/CHANGELOG.md b/services/analysisservices/mgmt/2017-07-14/analysisservices/CHANGELOG.md new file mode 100644 index 000000000000..8d5d2ab27178 --- /dev/null +++ b/services/analysisservices/mgmt/2017-07-14/analysisservices/CHANGELOG.md @@ -0,0 +1,4 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82 + +Code generator @microsoft.azure/autorest.go@~2.1.161 + diff --git a/services/analysisservices/mgmt/2017-07-14/analysisservices/analysisservicesapi/interfaces.go b/services/analysisservices/mgmt/2017-07-14/analysisservices/analysisservicesapi/interfaces.go index 8c31e3b8805b..d1cc85a233a7 100644 --- a/services/analysisservices/mgmt/2017-07-14/analysisservices/analysisservicesapi/interfaces.go +++ b/services/analysisservices/mgmt/2017-07-14/analysisservices/analysisservicesapi/interfaces.go @@ -43,3 +43,11 @@ type ServersClientAPI interface { } var _ ServersClientAPI = (*analysisservices.ServersClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result analysisservices.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result analysisservices.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*analysisservices.OperationsClient)(nil) diff --git a/services/analysisservices/mgmt/2017-07-14/analysisservices/models.go b/services/analysisservices/mgmt/2017-07-14/analysisservices/models.go index a9de6879a66c..4a66a7d571e6 100644 --- a/services/analysisservices/mgmt/2017-07-14/analysisservices/models.go +++ b/services/analysisservices/mgmt/2017-07-14/analysisservices/models.go @@ -22,6 +22,8 @@ import ( "encoding/json" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" "net/http" ) @@ -95,6 +97,215 @@ type GatewayListStatusLive struct { Status Status `json:"status,omitempty"` } +// OperationDetail a Consumption REST API operation. +type OperationDetail struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Display of the operation + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDetail. +func (od OperationDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if od.IsDataAction != nil { + objectMap["isDataAction"] = od.IsDataAction + } + if od.Display != nil { + objectMap["display"] = od.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.Consumption. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed: UsageDetail, etc. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description for the operation + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if od.Description != nil { + objectMap["description"] = od.Description + } + return json.Marshal(objectMap) +} + +// OperationListResult result of listing consumption 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 - READ-ONLY; List of analysis services operations supported by the Microsoft.AnalysisServices resource provider. + Value *[]OperationDetail `json:"value,omitempty"` + // NextLink - READ-ONLY; 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 OperationDetail values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// 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() OperationDetail { + if !iter.page.NotDone() { + return OperationDetail{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of OperationDetail values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext 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) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// 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. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// 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() []OperationDetail { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationsErrorResponse an error response from Operations. +type OperationsErrorResponse struct { + // Error - Error message from Operations. + Error *ErrorResponse `json:"error,omitempty"` +} + // OperationStatus the status of operation. type OperationStatus struct { autorest.Response `json:"-"` @@ -272,7 +483,8 @@ type ServerAdministrators struct { Members *[]string `json:"members,omitempty"` } -// ServerMutableProperties an object that represents a set of mutable Analysis Services resource properties. +// ServerMutableProperties an object that represents a set of mutable Analysis Services resource +// properties. type ServerMutableProperties struct { // AsAdministrators - A collection of AS server administrators AsAdministrators *ServerAdministrators `json:"asAdministrators,omitempty"` @@ -320,7 +532,8 @@ type Servers struct { Value *[]Server `json:"value,omitempty"` } -// ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// ServersCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type ServersCreateFuture struct { azure.Future } @@ -348,7 +561,8 @@ func (future *ServersCreateFuture) Result(client ServersClient) (s Server, err e return } -// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// ServersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type ServersDeleteFuture struct { azure.Future } @@ -370,7 +584,8 @@ func (future *ServersDeleteFuture) Result(client ServersClient) (ar autorest.Res return } -// ServersResumeFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// ServersResumeFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type ServersResumeFuture struct { azure.Future } @@ -392,7 +607,8 @@ func (future *ServersResumeFuture) Result(client ServersClient) (ar autorest.Res return } -// ServersSuspendFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// ServersSuspendFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type ServersSuspendFuture struct { azure.Future } @@ -414,7 +630,8 @@ func (future *ServersSuspendFuture) Result(client ServersClient) (ar autorest.Re return } -// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +// ServersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. type ServersUpdateFuture struct { azure.Future } @@ -515,7 +732,8 @@ type SkuDetailsForExistingResource struct { Sku *ResourceSku `json:"sku,omitempty"` } -// SkuEnumerationForExistingResourceResult an object that represents enumerating SKUs for existing resources +// SkuEnumerationForExistingResourceResult an object that represents enumerating SKUs for existing +// resources type SkuEnumerationForExistingResourceResult struct { autorest.Response `json:"-"` // Value - The collection of available SKUs for existing resources diff --git a/services/analysisservices/mgmt/2017-07-14/analysisservices/operations.go b/services/analysisservices/mgmt/2017-07-14/analysisservices/operations.go new file mode 100644 index 000000000000..39618bd6b14a --- /dev/null +++ b/services/analysisservices/mgmt/2017-07-14/analysisservices/operations.go @@ -0,0 +1,150 @@ +package analysisservices + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the the Azure Analysis Services Web API provides a RESTful set of web services that enables +// users to create, retrieve, update, and delete Analysis Services servers +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available consumption REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "analysisservices.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.OperationsClient", "List", resp, "Failure responding to request") + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-07-14" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AnalysisServices/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "analysisservices.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "analysisservices.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "analysisservices.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +}