...

Source file src/github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-07-01/containerservice/containerservices.go

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

     1  package containerservice
     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/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // ContainerServicesClient is the the Container Service Client.
    19  type ContainerServicesClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewContainerServicesClient creates an instance of the ContainerServicesClient client.
    24  func NewContainerServicesClient(subscriptionID string) ContainerServicesClient {
    25  	return NewContainerServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewContainerServicesClientWithBaseURI creates an instance of the ContainerServicesClient client using a custom
    29  // endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
    30  // stack).
    31  func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string) ContainerServicesClient {
    32  	return ContainerServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate creates or updates a container service with the specified configuration of orchestrator, masters, and
    36  // agents.
    37  // Parameters:
    38  // resourceGroupName - the name of the resource group.
    39  // containerServiceName - the name of the container service in the specified subscription and resource group.
    40  // parameters - parameters supplied to the Create or Update a Container Service operation.
    41  func (client ContainerServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (result ContainerServicesCreateOrUpdateFutureType, err error) {
    42  	if tracing.IsEnabled() {
    43  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.CreateOrUpdate")
    44  		defer func() {
    45  			sc := -1
    46  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    47  				sc = result.FutureAPI.Response().StatusCode
    48  			}
    49  			tracing.EndSpan(ctx, sc, err)
    50  		}()
    51  	}
    52  	if err := validation.Validate([]validation.Validation{
    53  		{TargetValue: parameters,
    54  			Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false,
    55  				Chain: []validation.Constraint{{Target: "parameters.Properties.OrchestratorProfile", Name: validation.Null, Rule: true, Chain: nil},
    56  					{Target: "parameters.Properties.CustomProfile", Name: validation.Null, Rule: false,
    57  						Chain: []validation.Constraint{{Target: "parameters.Properties.CustomProfile.Orchestrator", Name: validation.Null, Rule: true, Chain: nil}}},
    58  					{Target: "parameters.Properties.ServicePrincipalProfile", Name: validation.Null, Rule: false,
    59  						Chain: []validation.Constraint{{Target: "parameters.Properties.ServicePrincipalProfile.ClientID", Name: validation.Null, Rule: true, Chain: nil},
    60  							{Target: "parameters.Properties.ServicePrincipalProfile.KeyVaultSecretRef", Name: validation.Null, Rule: false,
    61  								Chain: []validation.Constraint{{Target: "parameters.Properties.ServicePrincipalProfile.KeyVaultSecretRef.VaultID", Name: validation.Null, Rule: true, Chain: nil},
    62  									{Target: "parameters.Properties.ServicePrincipalProfile.KeyVaultSecretRef.SecretName", Name: validation.Null, Rule: true, Chain: nil},
    63  								}},
    64  						}},
    65  					{Target: "parameters.Properties.MasterProfile", Name: validation.Null, Rule: true,
    66  						Chain: []validation.Constraint{{Target: "parameters.Properties.MasterProfile.DNSPrefix", Name: validation.Null, Rule: true, Chain: nil}}},
    67  					{Target: "parameters.Properties.WindowsProfile", Name: validation.Null, Rule: false,
    68  						Chain: []validation.Constraint{{Target: "parameters.Properties.WindowsProfile.AdminUsername", Name: validation.Null, Rule: true,
    69  							Chain: []validation.Constraint{{Target: "parameters.Properties.WindowsProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$`, Chain: nil}}},
    70  							{Target: "parameters.Properties.WindowsProfile.AdminPassword", Name: validation.Null, Rule: true, Chain: nil},
    71  						}},
    72  					{Target: "parameters.Properties.LinuxProfile", Name: validation.Null, Rule: true,
    73  						Chain: []validation.Constraint{{Target: "parameters.Properties.LinuxProfile.AdminUsername", Name: validation.Null, Rule: true,
    74  							Chain: []validation.Constraint{{Target: "parameters.Properties.LinuxProfile.AdminUsername", Name: validation.Pattern, Rule: `^[A-Za-z][-A-Za-z0-9_]*$`, Chain: nil}}},
    75  							{Target: "parameters.Properties.LinuxProfile.SSH", Name: validation.Null, Rule: true,
    76  								Chain: []validation.Constraint{{Target: "parameters.Properties.LinuxProfile.SSH.PublicKeys", Name: validation.Null, Rule: true, Chain: nil}}},
    77  						}},
    78  					{Target: "parameters.Properties.DiagnosticsProfile", Name: validation.Null, Rule: false,
    79  						Chain: []validation.Constraint{{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics", Name: validation.Null, Rule: true,
    80  							Chain: []validation.Constraint{{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}},
    81  						}},
    82  				}}}}}); err != nil {
    83  		return result, validation.NewError("containerservice.ContainerServicesClient", "CreateOrUpdate", err.Error())
    84  	}
    85  
    86  	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, containerServiceName, parameters)
    87  	if err != nil {
    88  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
    89  		return
    90  	}
    91  
    92  	result, err = client.CreateOrUpdateSender(req)
    93  	if err != nil {
    94  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
    95  		return
    96  	}
    97  
    98  	return
    99  }
   100  
   101  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   102  func (client ContainerServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (*http.Request, error) {
   103  	pathParameters := map[string]interface{}{
   104  		"containerServiceName": autorest.Encode("path", containerServiceName),
   105  		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
   106  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
   107  	}
   108  
   109  	const APIVersion = "2017-07-01"
   110  	queryParameters := map[string]interface{}{
   111  		"api-version": APIVersion,
   112  	}
   113  
   114  	preparer := autorest.CreatePreparer(
   115  		autorest.AsContentType("application/json; charset=utf-8"),
   116  		autorest.AsPut(),
   117  		autorest.WithBaseURL(client.BaseURI),
   118  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
   119  		autorest.WithJSON(parameters),
   120  		autorest.WithQueryParameters(queryParameters))
   121  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   122  }
   123  
   124  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   125  // http.Response Body if it receives an error.
   126  func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (future ContainerServicesCreateOrUpdateFutureType, err error) {
   127  	var resp *http.Response
   128  	future.FutureAPI = &azure.Future{}
   129  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   130  	if err != nil {
   131  		return
   132  	}
   133  	var azf azure.Future
   134  	azf, err = azure.NewFutureFromResponse(resp)
   135  	future.FutureAPI = &azf
   136  	future.Result = future.result
   137  	return
   138  }
   139  
   140  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   141  // closes the http.Response Body.
   142  func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) {
   143  	err = autorest.Respond(
   144  		resp,
   145  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
   146  		autorest.ByUnmarshallingJSON(&result),
   147  		autorest.ByClosing())
   148  	result.Response = autorest.Response{Response: resp}
   149  	return
   150  }
   151  
   152  // Delete deletes the specified container service in the specified subscription and resource group. The operation does
   153  // not delete other resources created as part of creating a container service, including storage accounts, VMs, and
   154  // availability sets. All the other resources created with the container service are part of the same resource group
   155  // and can be deleted individually.
   156  // Parameters:
   157  // resourceGroupName - the name of the resource group.
   158  // containerServiceName - the name of the container service in the specified subscription and resource group.
   159  func (client ContainerServicesClient) Delete(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerServicesDeleteFutureType, err error) {
   160  	if tracing.IsEnabled() {
   161  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.Delete")
   162  		defer func() {
   163  			sc := -1
   164  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   165  				sc = result.FutureAPI.Response().StatusCode
   166  			}
   167  			tracing.EndSpan(ctx, sc, err)
   168  		}()
   169  	}
   170  	req, err := client.DeletePreparer(ctx, resourceGroupName, containerServiceName)
   171  	if err != nil {
   172  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", nil, "Failure preparing request")
   173  		return
   174  	}
   175  
   176  	result, err = client.DeleteSender(req)
   177  	if err != nil {
   178  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", result.Response(), "Failure sending request")
   179  		return
   180  	}
   181  
   182  	return
   183  }
   184  
   185  // DeletePreparer prepares the Delete request.
   186  func (client ContainerServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
   187  	pathParameters := map[string]interface{}{
   188  		"containerServiceName": autorest.Encode("path", containerServiceName),
   189  		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
   190  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
   191  	}
   192  
   193  	const APIVersion = "2017-07-01"
   194  	queryParameters := map[string]interface{}{
   195  		"api-version": APIVersion,
   196  	}
   197  
   198  	preparer := autorest.CreatePreparer(
   199  		autorest.AsDelete(),
   200  		autorest.WithBaseURL(client.BaseURI),
   201  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
   202  		autorest.WithQueryParameters(queryParameters))
   203  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   204  }
   205  
   206  // DeleteSender sends the Delete request. The method will close the
   207  // http.Response Body if it receives an error.
   208  func (client ContainerServicesClient) DeleteSender(req *http.Request) (future ContainerServicesDeleteFutureType, err error) {
   209  	var resp *http.Response
   210  	future.FutureAPI = &azure.Future{}
   211  	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
   212  	if err != nil {
   213  		return
   214  	}
   215  	var azf azure.Future
   216  	azf, err = azure.NewFutureFromResponse(resp)
   217  	future.FutureAPI = &azf
   218  	future.Result = future.result
   219  	return
   220  }
   221  
   222  // DeleteResponder handles the response to the Delete request. The method always
   223  // closes the http.Response Body.
   224  func (client ContainerServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   225  	err = autorest.Respond(
   226  		resp,
   227  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   228  		autorest.ByClosing())
   229  	result.Response = resp
   230  	return
   231  }
   232  
   233  // Get gets the properties of the specified container service in the specified subscription and resource group. The
   234  // operation returns the properties including state, orchestrator, number of masters and agents, and FQDNs of masters
   235  // and agents.
   236  // Parameters:
   237  // resourceGroupName - the name of the resource group.
   238  // containerServiceName - the name of the container service in the specified subscription and resource group.
   239  func (client ContainerServicesClient) Get(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerService, err error) {
   240  	if tracing.IsEnabled() {
   241  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.Get")
   242  		defer func() {
   243  			sc := -1
   244  			if result.Response.Response != nil {
   245  				sc = result.Response.Response.StatusCode
   246  			}
   247  			tracing.EndSpan(ctx, sc, err)
   248  		}()
   249  	}
   250  	req, err := client.GetPreparer(ctx, resourceGroupName, containerServiceName)
   251  	if err != nil {
   252  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", nil, "Failure preparing request")
   253  		return
   254  	}
   255  
   256  	resp, err := client.GetSender(req)
   257  	if err != nil {
   258  		result.Response = autorest.Response{Response: resp}
   259  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure sending request")
   260  		return
   261  	}
   262  
   263  	result, err = client.GetResponder(resp)
   264  	if err != nil {
   265  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure responding to request")
   266  		return
   267  	}
   268  
   269  	return
   270  }
   271  
   272  // GetPreparer prepares the Get request.
   273  func (client ContainerServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
   274  	pathParameters := map[string]interface{}{
   275  		"containerServiceName": autorest.Encode("path", containerServiceName),
   276  		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
   277  		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
   278  	}
   279  
   280  	const APIVersion = "2017-07-01"
   281  	queryParameters := map[string]interface{}{
   282  		"api-version": APIVersion,
   283  	}
   284  
   285  	preparer := autorest.CreatePreparer(
   286  		autorest.AsGet(),
   287  		autorest.WithBaseURL(client.BaseURI),
   288  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
   289  		autorest.WithQueryParameters(queryParameters))
   290  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   291  }
   292  
   293  // GetSender sends the Get request. The method will close the
   294  // http.Response Body if it receives an error.
   295  func (client ContainerServicesClient) GetSender(req *http.Request) (*http.Response, error) {
   296  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   297  }
   298  
   299  // GetResponder handles the response to the Get request. The method always
   300  // closes the http.Response Body.
   301  func (client ContainerServicesClient) GetResponder(resp *http.Response) (result ContainerService, err error) {
   302  	err = autorest.Respond(
   303  		resp,
   304  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   305  		autorest.ByUnmarshallingJSON(&result),
   306  		autorest.ByClosing())
   307  	result.Response = autorest.Response{Response: resp}
   308  	return
   309  }
   310  
   311  // List gets a list of container services in the specified subscription. The operation returns properties of each
   312  // container service including state, orchestrator, number of masters and agents, and FQDNs of masters and agents.
   313  func (client ContainerServicesClient) List(ctx context.Context) (result ListResultPage, err error) {
   314  	if tracing.IsEnabled() {
   315  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.List")
   316  		defer func() {
   317  			sc := -1
   318  			if result.lr.Response.Response != nil {
   319  				sc = result.lr.Response.Response.StatusCode
   320  			}
   321  			tracing.EndSpan(ctx, sc, err)
   322  		}()
   323  	}
   324  	result.fn = client.listNextResults
   325  	req, err := client.ListPreparer(ctx)
   326  	if err != nil {
   327  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing request")
   328  		return
   329  	}
   330  
   331  	resp, err := client.ListSender(req)
   332  	if err != nil {
   333  		result.lr.Response = autorest.Response{Response: resp}
   334  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending request")
   335  		return
   336  	}
   337  
   338  	result.lr, err = client.ListResponder(resp)
   339  	if err != nil {
   340  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure responding to request")
   341  		return
   342  	}
   343  	if result.lr.hasNextLink() && result.lr.IsEmpty() {
   344  		err = result.NextWithContext(ctx)
   345  		return
   346  	}
   347  
   348  	return
   349  }
   350  
   351  // ListPreparer prepares the List request.
   352  func (client ContainerServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
   353  	pathParameters := map[string]interface{}{
   354  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   355  	}
   356  
   357  	const APIVersion = "2017-07-01"
   358  	queryParameters := map[string]interface{}{
   359  		"api-version": APIVersion,
   360  	}
   361  
   362  	preparer := autorest.CreatePreparer(
   363  		autorest.AsGet(),
   364  		autorest.WithBaseURL(client.BaseURI),
   365  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/containerServices", pathParameters),
   366  		autorest.WithQueryParameters(queryParameters))
   367  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   368  }
   369  
   370  // ListSender sends the List request. The method will close the
   371  // http.Response Body if it receives an error.
   372  func (client ContainerServicesClient) ListSender(req *http.Request) (*http.Response, error) {
   373  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   374  }
   375  
   376  // ListResponder handles the response to the List request. The method always
   377  // closes the http.Response Body.
   378  func (client ContainerServicesClient) ListResponder(resp *http.Response) (result ListResult, err error) {
   379  	err = autorest.Respond(
   380  		resp,
   381  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   382  		autorest.ByUnmarshallingJSON(&result),
   383  		autorest.ByClosing())
   384  	result.Response = autorest.Response{Response: resp}
   385  	return
   386  }
   387  
   388  // listNextResults retrieves the next set of results, if any.
   389  func (client ContainerServicesClient) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
   390  	req, err := lastResults.listResultPreparer(ctx)
   391  	if err != nil {
   392  		return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "listNextResults", nil, "Failure preparing next results request")
   393  	}
   394  	if req == nil {
   395  		return
   396  	}
   397  	resp, err := client.ListSender(req)
   398  	if err != nil {
   399  		result.Response = autorest.Response{Response: resp}
   400  		return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "listNextResults", resp, "Failure sending next results request")
   401  	}
   402  	result, err = client.ListResponder(resp)
   403  	if err != nil {
   404  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "listNextResults", resp, "Failure responding to next results request")
   405  	}
   406  	return
   407  }
   408  
   409  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   410  func (client ContainerServicesClient) ListComplete(ctx context.Context) (result ListResultIterator, err error) {
   411  	if tracing.IsEnabled() {
   412  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.List")
   413  		defer func() {
   414  			sc := -1
   415  			if result.Response().Response.Response != nil {
   416  				sc = result.page.Response().Response.Response.StatusCode
   417  			}
   418  			tracing.EndSpan(ctx, sc, err)
   419  		}()
   420  	}
   421  	result.page, err = client.List(ctx)
   422  	return
   423  }
   424  
   425  // ListByResourceGroup gets a list of container services in the specified subscription and resource group. The
   426  // operation returns properties of each container service including state, orchestrator, number of masters and agents,
   427  // and FQDNs of masters and agents.
   428  // Parameters:
   429  // resourceGroupName - the name of the resource group.
   430  func (client ContainerServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListResultPage, err error) {
   431  	if tracing.IsEnabled() {
   432  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListByResourceGroup")
   433  		defer func() {
   434  			sc := -1
   435  			if result.lr.Response.Response != nil {
   436  				sc = result.lr.Response.Response.StatusCode
   437  			}
   438  			tracing.EndSpan(ctx, sc, err)
   439  		}()
   440  	}
   441  	result.fn = client.listByResourceGroupNextResults
   442  	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
   443  	if err != nil {
   444  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
   445  		return
   446  	}
   447  
   448  	resp, err := client.ListByResourceGroupSender(req)
   449  	if err != nil {
   450  		result.lr.Response = autorest.Response{Response: resp}
   451  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request")
   452  		return
   453  	}
   454  
   455  	result.lr, err = client.ListByResourceGroupResponder(resp)
   456  	if err != nil {
   457  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
   458  		return
   459  	}
   460  	if result.lr.hasNextLink() && result.lr.IsEmpty() {
   461  		err = result.NextWithContext(ctx)
   462  		return
   463  	}
   464  
   465  	return
   466  }
   467  
   468  // ListByResourceGroupPreparer prepares the ListByResourceGroup request.
   469  func (client ContainerServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
   470  	pathParameters := map[string]interface{}{
   471  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   472  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   473  	}
   474  
   475  	const APIVersion = "2017-07-01"
   476  	queryParameters := map[string]interface{}{
   477  		"api-version": APIVersion,
   478  	}
   479  
   480  	preparer := autorest.CreatePreparer(
   481  		autorest.AsGet(),
   482  		autorest.WithBaseURL(client.BaseURI),
   483  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices", pathParameters),
   484  		autorest.WithQueryParameters(queryParameters))
   485  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   486  }
   487  
   488  // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
   489  // http.Response Body if it receives an error.
   490  func (client ContainerServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
   491  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   492  }
   493  
   494  // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
   495  // closes the http.Response Body.
   496  func (client ContainerServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) {
   497  	err = autorest.Respond(
   498  		resp,
   499  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   500  		autorest.ByUnmarshallingJSON(&result),
   501  		autorest.ByClosing())
   502  	result.Response = autorest.Response{Response: resp}
   503  	return
   504  }
   505  
   506  // listByResourceGroupNextResults retrieves the next set of results, if any.
   507  func (client ContainerServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
   508  	req, err := lastResults.listResultPreparer(ctx)
   509  	if err != nil {
   510  		return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
   511  	}
   512  	if req == nil {
   513  		return
   514  	}
   515  	resp, err := client.ListByResourceGroupSender(req)
   516  	if err != nil {
   517  		result.Response = autorest.Response{Response: resp}
   518  		return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
   519  	}
   520  	result, err = client.ListByResourceGroupResponder(resp)
   521  	if err != nil {
   522  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
   523  	}
   524  	return
   525  }
   526  
   527  // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
   528  func (client ContainerServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListResultIterator, err error) {
   529  	if tracing.IsEnabled() {
   530  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListByResourceGroup")
   531  		defer func() {
   532  			sc := -1
   533  			if result.Response().Response.Response != nil {
   534  				sc = result.page.Response().Response.Response.StatusCode
   535  			}
   536  			tracing.EndSpan(ctx, sc, err)
   537  		}()
   538  	}
   539  	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
   540  	return
   541  }
   542  
   543  // ListOrchestrators gets a list of supported orchestrators in the specified subscription. The operation returns
   544  // properties of each orchestrator including version, available upgrades and whether that version or upgrades are in
   545  // preview.
   546  // Parameters:
   547  // location - the name of a supported Azure region.
   548  // resourceType - resource type for which the list of orchestrators needs to be returned
   549  func (client ContainerServicesClient) ListOrchestrators(ctx context.Context, location string, resourceType string) (result OrchestratorVersionProfileListResult, err error) {
   550  	if tracing.IsEnabled() {
   551  		ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListOrchestrators")
   552  		defer func() {
   553  			sc := -1
   554  			if result.Response.Response != nil {
   555  				sc = result.Response.Response.StatusCode
   556  			}
   557  			tracing.EndSpan(ctx, sc, err)
   558  		}()
   559  	}
   560  	req, err := client.ListOrchestratorsPreparer(ctx, location, resourceType)
   561  	if err != nil {
   562  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListOrchestrators", nil, "Failure preparing request")
   563  		return
   564  	}
   565  
   566  	resp, err := client.ListOrchestratorsSender(req)
   567  	if err != nil {
   568  		result.Response = autorest.Response{Response: resp}
   569  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListOrchestrators", resp, "Failure sending request")
   570  		return
   571  	}
   572  
   573  	result, err = client.ListOrchestratorsResponder(resp)
   574  	if err != nil {
   575  		err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListOrchestrators", resp, "Failure responding to request")
   576  		return
   577  	}
   578  
   579  	return
   580  }
   581  
   582  // ListOrchestratorsPreparer prepares the ListOrchestrators request.
   583  func (client ContainerServicesClient) ListOrchestratorsPreparer(ctx context.Context, location string, resourceType string) (*http.Request, error) {
   584  	pathParameters := map[string]interface{}{
   585  		"location":       autorest.Encode("path", location),
   586  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
   587  	}
   588  
   589  	const APIVersion = "2019-08-01"
   590  	queryParameters := map[string]interface{}{
   591  		"api-version": APIVersion,
   592  	}
   593  	if len(resourceType) > 0 {
   594  		queryParameters["resource-type"] = autorest.Encode("query", resourceType)
   595  	}
   596  
   597  	preparer := autorest.CreatePreparer(
   598  		autorest.AsGet(),
   599  		autorest.WithBaseURL(client.BaseURI),
   600  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/locations/{location}/orchestrators", pathParameters),
   601  		autorest.WithQueryParameters(queryParameters))
   602  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   603  }
   604  
   605  // ListOrchestratorsSender sends the ListOrchestrators request. The method will close the
   606  // http.Response Body if it receives an error.
   607  func (client ContainerServicesClient) ListOrchestratorsSender(req *http.Request) (*http.Response, error) {
   608  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   609  }
   610  
   611  // ListOrchestratorsResponder handles the response to the ListOrchestrators request. The method always
   612  // closes the http.Response Body.
   613  func (client ContainerServicesClient) ListOrchestratorsResponder(resp *http.Response) (result OrchestratorVersionProfileListResult, err error) {
   614  	err = autorest.Respond(
   615  		resp,
   616  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   617  		autorest.ByUnmarshallingJSON(&result),
   618  		autorest.ByClosing())
   619  	result.Response = autorest.Response{Response: resp}
   620  	return
   621  }
   622  

View as plain text