...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2021-11-01-preview/insights/operations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/appinsights/mgmt/2021-11-01-preview/insights

     1  package insights
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/tracing"
    14  	"net/http"
    15  )
    16  
    17  // OperationsClient is the composite Swagger for Application Insights Management Client
    18  type OperationsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewOperationsClient creates an instance of the OperationsClient client.
    23  func NewOperationsClient(subscriptionID string) OperationsClient {
    24  	return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint.  Use this
    28  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    29  func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
    30  	return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    31  }
    32  
    33  // List lists all of the available insights REST API operations.
    34  func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) {
    35  	if tracing.IsEnabled() {
    36  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
    37  		defer func() {
    38  			sc := -1
    39  			if result.olr.Response.Response != nil {
    40  				sc = result.olr.Response.Response.StatusCode
    41  			}
    42  			tracing.EndSpan(ctx, sc, err)
    43  		}()
    44  	}
    45  	result.fn = client.listNextResults
    46  	req, err := client.ListPreparer(ctx)
    47  	if err != nil {
    48  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", nil, "Failure preparing request")
    49  		return
    50  	}
    51  
    52  	resp, err := client.ListSender(req)
    53  	if err != nil {
    54  		result.olr.Response = autorest.Response{Response: resp}
    55  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure sending request")
    56  		return
    57  	}
    58  
    59  	result.olr, err = client.ListResponder(resp)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List", resp, "Failure responding to request")
    62  		return
    63  	}
    64  	if result.olr.hasNextLink() && result.olr.IsEmpty() {
    65  		err = result.NextWithContext(ctx)
    66  		return
    67  	}
    68  
    69  	return
    70  }
    71  
    72  // ListPreparer prepares the List request.
    73  func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
    74  	const APIVersion = "2015-05-01"
    75  	queryParameters := map[string]interface{}{
    76  		"api-version": APIVersion,
    77  	}
    78  
    79  	preparer := autorest.CreatePreparer(
    80  		autorest.AsGet(),
    81  		autorest.WithBaseURL(client.BaseURI),
    82  		autorest.WithPath("/providers/Microsoft.Insights/operations"),
    83  		autorest.WithQueryParameters(queryParameters))
    84  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    85  }
    86  
    87  // ListSender sends the List request. The method will close the
    88  // http.Response Body if it receives an error.
    89  func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
    90  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    91  }
    92  
    93  // ListResponder handles the response to the List request. The method always
    94  // closes the http.Response Body.
    95  func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) {
    96  	err = autorest.Respond(
    97  		resp,
    98  		azure.WithErrorUnlessStatusCode(http.StatusOK),
    99  		autorest.ByUnmarshallingJSON(&result),
   100  		autorest.ByClosing())
   101  	result.Response = autorest.Response{Response: resp}
   102  	return
   103  }
   104  
   105  // listNextResults retrieves the next set of results, if any.
   106  func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) {
   107  	req, err := lastResults.operationListResultPreparer(ctx)
   108  	if err != nil {
   109  		return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", nil, "Failure preparing next results request")
   110  	}
   111  	if req == nil {
   112  		return
   113  	}
   114  	resp, err := client.ListSender(req)
   115  	if err != nil {
   116  		result.Response = autorest.Response{Response: resp}
   117  		return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", resp, "Failure sending next results request")
   118  	}
   119  	result, err = client.ListResponder(resp)
   120  	if err != nil {
   121  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "listNextResults", resp, "Failure responding to next results request")
   122  	}
   123  	return
   124  }
   125  
   126  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   127  func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) {
   128  	if tracing.IsEnabled() {
   129  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List")
   130  		defer func() {
   131  			sc := -1
   132  			if result.Response().Response.Response != nil {
   133  				sc = result.page.Response().Response.Response.StatusCode
   134  			}
   135  			tracing.EndSpan(ctx, sc, err)
   136  		}()
   137  	}
   138  	result.page, err = client.List(ctx)
   139  	return
   140  }
   141  
   142  // List1 list the available operations supported by the resource provider.
   143  func (client OperationsClient) List1(ctx context.Context) (result OperationsListResultPage, err error) {
   144  	if tracing.IsEnabled() {
   145  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List1")
   146  		defer func() {
   147  			sc := -1
   148  			if result.olr.Response.Response != nil {
   149  				sc = result.olr.Response.Response.StatusCode
   150  			}
   151  			tracing.EndSpan(ctx, sc, err)
   152  		}()
   153  	}
   154  	result.fn = client.list1NextResults
   155  	req, err := client.List1Preparer(ctx)
   156  	if err != nil {
   157  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List1", nil, "Failure preparing request")
   158  		return
   159  	}
   160  
   161  	resp, err := client.List1Sender(req)
   162  	if err != nil {
   163  		result.olr.Response = autorest.Response{Response: resp}
   164  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List1", resp, "Failure sending request")
   165  		return
   166  	}
   167  
   168  	result.olr, err = client.List1Responder(resp)
   169  	if err != nil {
   170  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "List1", resp, "Failure responding to request")
   171  		return
   172  	}
   173  	if result.olr.hasNextLink() && result.olr.IsEmpty() {
   174  		err = result.NextWithContext(ctx)
   175  		return
   176  	}
   177  
   178  	return
   179  }
   180  
   181  // List1Preparer prepares the List1 request.
   182  func (client OperationsClient) List1Preparer(ctx context.Context) (*http.Request, error) {
   183  	const APIVersion = "2020-06-02-preview"
   184  	queryParameters := map[string]interface{}{
   185  		"api-version": APIVersion,
   186  	}
   187  
   188  	preparer := autorest.CreatePreparer(
   189  		autorest.AsGet(),
   190  		autorest.WithBaseURL(client.BaseURI),
   191  		autorest.WithPath("/providers/microsoft.insights/operations"),
   192  		autorest.WithQueryParameters(queryParameters))
   193  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   194  }
   195  
   196  // List1Sender sends the List1 request. The method will close the
   197  // http.Response Body if it receives an error.
   198  func (client OperationsClient) List1Sender(req *http.Request) (*http.Response, error) {
   199  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   200  }
   201  
   202  // List1Responder handles the response to the List1 request. The method always
   203  // closes the http.Response Body.
   204  func (client OperationsClient) List1Responder(resp *http.Response) (result OperationsListResult, err error) {
   205  	err = autorest.Respond(
   206  		resp,
   207  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   208  		autorest.ByUnmarshallingJSON(&result),
   209  		autorest.ByClosing())
   210  	result.Response = autorest.Response{Response: resp}
   211  	return
   212  }
   213  
   214  // list1NextResults retrieves the next set of results, if any.
   215  func (client OperationsClient) list1NextResults(ctx context.Context, lastResults OperationsListResult) (result OperationsListResult, err error) {
   216  	req, err := lastResults.operationsListResultPreparer(ctx)
   217  	if err != nil {
   218  		return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "list1NextResults", nil, "Failure preparing next results request")
   219  	}
   220  	if req == nil {
   221  		return
   222  	}
   223  	resp, err := client.List1Sender(req)
   224  	if err != nil {
   225  		result.Response = autorest.Response{Response: resp}
   226  		return result, autorest.NewErrorWithError(err, "insights.OperationsClient", "list1NextResults", resp, "Failure sending next results request")
   227  	}
   228  	result, err = client.List1Responder(resp)
   229  	if err != nil {
   230  		err = autorest.NewErrorWithError(err, "insights.OperationsClient", "list1NextResults", resp, "Failure responding to next results request")
   231  	}
   232  	return
   233  }
   234  
   235  // List1Complete enumerates all values, automatically crossing page boundaries as required.
   236  func (client OperationsClient) List1Complete(ctx context.Context) (result OperationsListResultIterator, err error) {
   237  	if tracing.IsEnabled() {
   238  		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List1")
   239  		defer func() {
   240  			sc := -1
   241  			if result.Response().Response.Response != nil {
   242  				sc = result.page.Response().Response.Response.StatusCode
   243  			}
   244  			tracing.EndSpan(ctx, sc, err)
   245  		}()
   246  	}
   247  	result.page, err = client.List1(ctx)
   248  	return
   249  }
   250  

View as plain text