1package signalr 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 "net/http" 25) 26 27// OperationsClient is the REST API for Azure SignalR Service 28type OperationsClient struct { 29 BaseClient 30} 31 32// NewOperationsClient creates an instance of the OperationsClient client. 33func NewOperationsClient(subscriptionID string) OperationsClient { 34 return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. 38func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { 39 return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} 40} 41 42// List lists all of the available REST API operations of the Microsoft.SignalRService provider. 43func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { 44 result.fn = client.listNextResults 45 req, err := client.ListPreparer(ctx) 46 if err != nil { 47 err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "List", nil, "Failure preparing request") 48 return 49 } 50 51 resp, err := client.ListSender(req) 52 if err != nil { 53 result.ol.Response = autorest.Response{Response: resp} 54 err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "List", resp, "Failure sending request") 55 return 56 } 57 58 result.ol, err = client.ListResponder(resp) 59 if err != nil { 60 err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "List", resp, "Failure responding to request") 61 } 62 63 return 64} 65 66// ListPreparer prepares the List request. 67func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 68 const APIVersion = "2018-03-01-preview" 69 queryParameters := map[string]interface{}{ 70 "api-version": APIVersion, 71 } 72 73 preparer := autorest.CreatePreparer( 74 autorest.AsGet(), 75 autorest.WithBaseURL(client.BaseURI), 76 autorest.WithPath("/providers/Microsoft.SignalRService/operations"), 77 autorest.WithQueryParameters(queryParameters)) 78 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 79} 80 81// ListSender sends the List request. The method will close the 82// http.Response Body if it receives an error. 83func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { 84 return autorest.SendWithSender(client, req, 85 autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 86} 87 88// ListResponder handles the response to the List request. The method always 89// closes the http.Response Body. 90func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { 91 err = autorest.Respond( 92 resp, 93 client.ByInspecting(), 94 azure.WithErrorUnlessStatusCode(http.StatusOK), 95 autorest.ByUnmarshallingJSON(&result), 96 autorest.ByClosing()) 97 result.Response = autorest.Response{Response: resp} 98 return 99} 100 101// listNextResults retrieves the next set of results, if any. 102func (client OperationsClient) listNextResults(lastResults OperationList) (result OperationList, err error) { 103 req, err := lastResults.operationListPreparer() 104 if err != nil { 105 return result, autorest.NewErrorWithError(err, "signalr.OperationsClient", "listNextResults", nil, "Failure preparing next results request") 106 } 107 if req == nil { 108 return 109 } 110 resp, err := client.ListSender(req) 111 if err != nil { 112 result.Response = autorest.Response{Response: resp} 113 return result, autorest.NewErrorWithError(err, "signalr.OperationsClient", "listNextResults", resp, "Failure sending next results request") 114 } 115 result, err = client.ListResponder(resp) 116 if err != nil { 117 err = autorest.NewErrorWithError(err, "signalr.OperationsClient", "listNextResults", resp, "Failure responding to next results request") 118 } 119 return 120} 121 122// ListComplete enumerates all values, automatically crossing page boundaries as required. 123func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { 124 result.page, err = client.List(ctx) 125 return 126} 127