1package kusto 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/tracing" 25 "net/http" 26) 27 28// OperationsClient is the the Azure Kusto management API provides a RESTful set of web services that interact with 29// Azure Kusto services to manage your clusters and databases. The API enables you to create, update, and delete 30// clusters and databases. 31type OperationsClient struct { 32 BaseClient 33} 34 35// NewOperationsClient creates an instance of the OperationsClient client. 36func NewOperationsClient(subscriptionID string) OperationsClient { 37 return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 38} 39 40// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this 41// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 42func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { 43 return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// List lists available operations for the Microsoft.Kusto provider. 47func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { 48 if tracing.IsEnabled() { 49 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") 50 defer func() { 51 sc := -1 52 if result.olr.Response.Response != nil { 53 sc = result.olr.Response.Response.StatusCode 54 } 55 tracing.EndSpan(ctx, sc, err) 56 }() 57 } 58 result.fn = client.listNextResults 59 req, err := client.ListPreparer(ctx) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "kusto.OperationsClient", "List", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.ListSender(req) 66 if err != nil { 67 result.olr.Response = autorest.Response{Response: resp} 68 err = autorest.NewErrorWithError(err, "kusto.OperationsClient", "List", resp, "Failure sending request") 69 return 70 } 71 72 result.olr, err = client.ListResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "kusto.OperationsClient", "List", resp, "Failure responding to request") 75 return 76 } 77 if result.olr.hasNextLink() && result.olr.IsEmpty() { 78 err = result.NextWithContext(ctx) 79 return 80 } 81 82 return 83} 84 85// ListPreparer prepares the List request. 86func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 87 const APIVersion = "2020-09-18" 88 queryParameters := map[string]interface{}{ 89 "api-version": APIVersion, 90 } 91 92 preparer := autorest.CreatePreparer( 93 autorest.AsGet(), 94 autorest.WithBaseURL(client.BaseURI), 95 autorest.WithPath("/providers/Microsoft.Kusto/operations"), 96 autorest.WithQueryParameters(queryParameters)) 97 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 98} 99 100// ListSender sends the List request. The method will close the 101// http.Response Body if it receives an error. 102func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { 103 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 104} 105 106// ListResponder handles the response to the List request. The method always 107// closes the http.Response Body. 108func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { 109 err = autorest.Respond( 110 resp, 111 azure.WithErrorUnlessStatusCode(http.StatusOK), 112 autorest.ByUnmarshallingJSON(&result), 113 autorest.ByClosing()) 114 result.Response = autorest.Response{Response: resp} 115 return 116} 117 118// listNextResults retrieves the next set of results, if any. 119func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { 120 req, err := lastResults.operationListResultPreparer(ctx) 121 if err != nil { 122 return result, autorest.NewErrorWithError(err, "kusto.OperationsClient", "listNextResults", nil, "Failure preparing next results request") 123 } 124 if req == nil { 125 return 126 } 127 resp, err := client.ListSender(req) 128 if err != nil { 129 result.Response = autorest.Response{Response: resp} 130 return result, autorest.NewErrorWithError(err, "kusto.OperationsClient", "listNextResults", resp, "Failure sending next results request") 131 } 132 result, err = client.ListResponder(resp) 133 if err != nil { 134 err = autorest.NewErrorWithError(err, "kusto.OperationsClient", "listNextResults", resp, "Failure responding to next results request") 135 } 136 return 137} 138 139// ListComplete enumerates all values, automatically crossing page boundaries as required. 140func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { 141 if tracing.IsEnabled() { 142 ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") 143 defer func() { 144 sc := -1 145 if result.Response().Response.Response != nil { 146 sc = result.page.Response().Response.Response.StatusCode 147 } 148 tracing.EndSpan(ctx, sc, err) 149 }() 150 } 151 result.page, err = client.List(ctx) 152 return 153} 154