diff --git a/profiles/latest/containerservice/mgmt/containerservice/models.go b/profiles/latest/containerservice/mgmt/containerservice/models.go index 60ceff00e4c0..891b9ddc31a4 100644 --- a/profiles/latest/containerservice/mgmt/containerservice/models.go +++ b/profiles/latest/containerservice/mgmt/containerservice/models.go @@ -392,6 +392,7 @@ type ManagedClustersCreateOrUpdateFuture = original.ManagedClustersCreateOrUpdat type ManagedClustersDeleteFuture = original.ManagedClustersDeleteFuture type ManagedClustersResetAADProfileFuture = original.ManagedClustersResetAADProfileFuture type ManagedClustersResetServicePrincipalProfileFuture = original.ManagedClustersResetServicePrincipalProfileFuture +type ManagedClustersRotateClusterCertificatesFuture = original.ManagedClustersRotateClusterCertificatesFuture type ManagedClustersUpdateTagsFuture = original.ManagedClustersUpdateTagsFuture type MasterProfile = original.MasterProfile type NetworkProfile = original.NetworkProfile diff --git a/profiles/preview/containerservice/mgmt/containerservice/models.go b/profiles/preview/containerservice/mgmt/containerservice/models.go index b3daa584aa6e..c5f30d22039d 100644 --- a/profiles/preview/containerservice/mgmt/containerservice/models.go +++ b/profiles/preview/containerservice/mgmt/containerservice/models.go @@ -392,6 +392,7 @@ type ManagedClustersCreateOrUpdateFuture = original.ManagedClustersCreateOrUpdat type ManagedClustersDeleteFuture = original.ManagedClustersDeleteFuture type ManagedClustersResetAADProfileFuture = original.ManagedClustersResetAADProfileFuture type ManagedClustersResetServicePrincipalProfileFuture = original.ManagedClustersResetServicePrincipalProfileFuture +type ManagedClustersRotateClusterCertificatesFuture = original.ManagedClustersRotateClusterCertificatesFuture type ManagedClustersUpdateTagsFuture = original.ManagedClustersUpdateTagsFuture type MasterProfile = original.MasterProfile type NetworkProfile = original.NetworkProfile diff --git a/services/containerservice/mgmt/2019-10-01/containerservice/containerserviceapi/interfaces.go b/services/containerservice/mgmt/2019-10-01/containerservice/containerserviceapi/interfaces.go index ae30efca4ee4..833bc9ff4ff4 100644 --- a/services/containerservice/mgmt/2019-10-01/containerservice/containerserviceapi/interfaces.go +++ b/services/containerservice/mgmt/2019-10-01/containerservice/containerserviceapi/interfaces.go @@ -66,6 +66,7 @@ type ManagedClustersClientAPI interface { ListClusterUserCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result containerservice.CredentialResults, err error) ResetAADProfile(ctx context.Context, resourceGroupName string, resourceName string, parameters containerservice.ManagedClusterAADProfile) (result containerservice.ManagedClustersResetAADProfileFuture, err error) ResetServicePrincipalProfile(ctx context.Context, resourceGroupName string, resourceName string, parameters containerservice.ManagedClusterServicePrincipalProfile) (result containerservice.ManagedClustersResetServicePrincipalProfileFuture, err error) + RotateClusterCertificates(ctx context.Context, resourceGroupName string, resourceName string) (result containerservice.ManagedClustersRotateClusterCertificatesFuture, err error) UpdateTags(ctx context.Context, resourceGroupName string, resourceName string, parameters containerservice.TagsObject) (result containerservice.ManagedClustersUpdateTagsFuture, err error) } diff --git a/services/containerservice/mgmt/2019-10-01/containerservice/managedclusters.go b/services/containerservice/mgmt/2019-10-01/containerservice/managedclusters.go index 25ac943a4349..46ea1d25531b 100644 --- a/services/containerservice/mgmt/2019-10-01/containerservice/managedclusters.go +++ b/services/containerservice/mgmt/2019-10-01/containerservice/managedclusters.go @@ -1110,6 +1110,92 @@ func (client ManagedClustersClient) ResetServicePrincipalProfileResponder(resp * return } +// RotateClusterCertificates rotate certificates of a managed cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the managed cluster resource. +func (client ManagedClustersClient) RotateClusterCertificates(ctx context.Context, resourceGroupName string, resourceName string) (result ManagedClustersRotateClusterCertificatesFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ManagedClustersClient.RotateClusterCertificates") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("containerservice.ManagedClustersClient", "RotateClusterCertificates", err.Error()) + } + + req, err := client.RotateClusterCertificatesPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ManagedClustersClient", "RotateClusterCertificates", nil, "Failure preparing request") + return + } + + result, err = client.RotateClusterCertificatesSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ManagedClustersClient", "RotateClusterCertificates", result.Response(), "Failure sending request") + return + } + + return +} + +// RotateClusterCertificatesPreparer prepares the RotateClusterCertificates request. +func (client ManagedClustersClient) RotateClusterCertificatesPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-10-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}/rotateClusterCertificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RotateClusterCertificatesSender sends the RotateClusterCertificates request. The method will close the +// http.Response Body if it receives an error. +func (client ManagedClustersClient) RotateClusterCertificatesSender(req *http.Request) (future ManagedClustersRotateClusterCertificatesFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// RotateClusterCertificatesResponder handles the response to the RotateClusterCertificates request. The method always +// closes the http.Response Body. +func (client ManagedClustersClient) RotateClusterCertificatesResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // UpdateTags updates a managed cluster with the specified tags. // Parameters: // resourceGroupName - the name of the resource group. diff --git a/services/containerservice/mgmt/2019-10-01/containerservice/models.go b/services/containerservice/mgmt/2019-10-01/containerservice/models.go index 9d54e3cd6052..5396d66d0e72 100644 --- a/services/containerservice/mgmt/2019-10-01/containerservice/models.go +++ b/services/containerservice/mgmt/2019-10-01/containerservice/models.go @@ -2228,6 +2228,29 @@ func (future *ManagedClustersResetServicePrincipalProfileFuture) Result(client M return } +// ManagedClustersRotateClusterCertificatesFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type ManagedClustersRotateClusterCertificatesFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ManagedClustersRotateClusterCertificatesFuture) Result(client ManagedClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerservice.ManagedClustersRotateClusterCertificatesFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerservice.ManagedClustersRotateClusterCertificatesFuture") + return + } + ar.Response = future.Response() + return +} + // ManagedClustersUpdateTagsFuture an abstraction for monitoring and retrieving the results of a // long-running operation. type ManagedClustersUpdateTagsFuture struct {