...

Source file src/github.com/Azure/azure-sdk-for-go/services/domainservices/mgmt/2020-01-01/aad/oucontaineroperations.go

Documentation: github.com/Azure/azure-sdk-for-go/services/domainservices/mgmt/2020-01-01/aad

     1  package aad
     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  // OuContainerOperationsClient is the the AAD Domain Services API.
    18  type OuContainerOperationsClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewOuContainerOperationsClient creates an instance of the OuContainerOperationsClient client.
    23  func NewOuContainerOperationsClient(subscriptionID string) OuContainerOperationsClient {
    24  	return NewOuContainerOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewOuContainerOperationsClientWithBaseURI creates an instance of the OuContainerOperationsClient client using a
    28  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    29  // Azure stack).
    30  func NewOuContainerOperationsClientWithBaseURI(baseURI string, subscriptionID string) OuContainerOperationsClient {
    31  	return OuContainerOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // List lists all the available OuContainer operations.
    35  func (client OuContainerOperationsClient) List(ctx context.Context) (result OperationEntityListResultPage, err error) {
    36  	if tracing.IsEnabled() {
    37  		ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerOperationsClient.List")
    38  		defer func() {
    39  			sc := -1
    40  			if result.oelr.Response.Response != nil {
    41  				sc = result.oelr.Response.Response.StatusCode
    42  			}
    43  			tracing.EndSpan(ctx, sc, err)
    44  		}()
    45  	}
    46  	result.fn = client.listNextResults
    47  	req, err := client.ListPreparer(ctx)
    48  	if err != nil {
    49  		err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "List", nil, "Failure preparing request")
    50  		return
    51  	}
    52  
    53  	resp, err := client.ListSender(req)
    54  	if err != nil {
    55  		result.oelr.Response = autorest.Response{Response: resp}
    56  		err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "List", resp, "Failure sending request")
    57  		return
    58  	}
    59  
    60  	result.oelr, err = client.ListResponder(resp)
    61  	if err != nil {
    62  		err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "List", resp, "Failure responding to request")
    63  		return
    64  	}
    65  	if result.oelr.hasNextLink() && result.oelr.IsEmpty() {
    66  		err = result.NextWithContext(ctx)
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // ListPreparer prepares the List request.
    74  func (client OuContainerOperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
    75  	const APIVersion = "2020-01-01"
    76  	queryParameters := map[string]interface{}{
    77  		"api-version": APIVersion,
    78  	}
    79  
    80  	preparer := autorest.CreatePreparer(
    81  		autorest.AsGet(),
    82  		autorest.WithBaseURL(client.BaseURI),
    83  		autorest.WithPath("/providers/Microsoft.Aad/operations"),
    84  		autorest.WithQueryParameters(queryParameters))
    85  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    86  }
    87  
    88  // ListSender sends the List request. The method will close the
    89  // http.Response Body if it receives an error.
    90  func (client OuContainerOperationsClient) ListSender(req *http.Request) (*http.Response, error) {
    91  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    92  }
    93  
    94  // ListResponder handles the response to the List request. The method always
    95  // closes the http.Response Body.
    96  func (client OuContainerOperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) {
    97  	err = autorest.Respond(
    98  		resp,
    99  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   100  		autorest.ByUnmarshallingJSON(&result),
   101  		autorest.ByClosing())
   102  	result.Response = autorest.Response{Response: resp}
   103  	return
   104  }
   105  
   106  // listNextResults retrieves the next set of results, if any.
   107  func (client OuContainerOperationsClient) listNextResults(ctx context.Context, lastResults OperationEntityListResult) (result OperationEntityListResult, err error) {
   108  	req, err := lastResults.operationEntityListResultPreparer(ctx)
   109  	if err != nil {
   110  		return result, autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "listNextResults", nil, "Failure preparing next results request")
   111  	}
   112  	if req == nil {
   113  		return
   114  	}
   115  	resp, err := client.ListSender(req)
   116  	if err != nil {
   117  		result.Response = autorest.Response{Response: resp}
   118  		return result, autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "listNextResults", resp, "Failure sending next results request")
   119  	}
   120  	result, err = client.ListResponder(resp)
   121  	if err != nil {
   122  		err = autorest.NewErrorWithError(err, "aad.OuContainerOperationsClient", "listNextResults", resp, "Failure responding to next results request")
   123  	}
   124  	return
   125  }
   126  
   127  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   128  func (client OuContainerOperationsClient) ListComplete(ctx context.Context) (result OperationEntityListResultIterator, err error) {
   129  	if tracing.IsEnabled() {
   130  		ctx = tracing.StartSpan(ctx, fqdn+"/OuContainerOperationsClient.List")
   131  		defer func() {
   132  			sc := -1
   133  			if result.Response().Response.Response != nil {
   134  				sc = result.page.Response().Response.Response.StatusCode
   135  			}
   136  			tracing.EndSpan(ctx, sc, err)
   137  		}()
   138  	}
   139  	result.page, err = client.List(ctx)
   140  	return
   141  }
   142  

View as plain text