diff --git a/profiles/latest/network/mgmt/network/models.go b/profiles/latest/network/mgmt/network/models.go index 22912a9d3ab3..f08e35183916 100644 --- a/profiles/latest/network/mgmt/network/models.go +++ b/profiles/latest/network/mgmt/network/models.go @@ -1143,6 +1143,7 @@ type DdosProtectionPlanPropertiesFormat = original.DdosProtectionPlanPropertiesF type DdosProtectionPlansClient = original.DdosProtectionPlansClient type DdosProtectionPlansCreateOrUpdateFuture = original.DdosProtectionPlansCreateOrUpdateFuture type DdosProtectionPlansDeleteFuture = original.DdosProtectionPlansDeleteFuture +type DdosProtectionPlansUpdateTagsFuture = original.DdosProtectionPlansUpdateTagsFuture type DdosSettings = original.DdosSettings type DefaultSecurityRulesClient = original.DefaultSecurityRulesClient type Delegation = original.Delegation diff --git a/profiles/preview/network/mgmt/network/models.go b/profiles/preview/network/mgmt/network/models.go index f5c3daae5a2d..aaeae92927bd 100644 --- a/profiles/preview/network/mgmt/network/models.go +++ b/profiles/preview/network/mgmt/network/models.go @@ -1143,6 +1143,7 @@ type DdosProtectionPlanPropertiesFormat = original.DdosProtectionPlanPropertiesF type DdosProtectionPlansClient = original.DdosProtectionPlansClient type DdosProtectionPlansCreateOrUpdateFuture = original.DdosProtectionPlansCreateOrUpdateFuture type DdosProtectionPlansDeleteFuture = original.DdosProtectionPlansDeleteFuture +type DdosProtectionPlansUpdateTagsFuture = original.DdosProtectionPlansUpdateTagsFuture type DdosSettings = original.DdosSettings type DefaultSecurityRulesClient = original.DefaultSecurityRulesClient type Delegation = original.Delegation diff --git a/services/network/mgmt/2018-11-01/network/ddosprotectionplans.go b/services/network/mgmt/2018-11-01/network/ddosprotectionplans.go index 011e9c2d783d..a3a5db86755e 100644 --- a/services/network/mgmt/2018-11-01/network/ddosprotectionplans.go +++ b/services/network/mgmt/2018-11-01/network/ddosprotectionplans.go @@ -495,3 +495,83 @@ func (client DdosProtectionPlansClient) ListByResourceGroupComplete(ctx context. result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) return } + +// UpdateTags update a DDoS protection plan tags +// Parameters: +// resourceGroupName - the name of the resource group. +// ddosProtectionPlanName - the name of the DDoS protection plan. +// parameters - parameters supplied to the update DDoS protection plan resource tags. +func (client DdosProtectionPlansClient) UpdateTags(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject) (result DdosProtectionPlansUpdateTagsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.UpdateTags") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, ddosProtectionPlanName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", nil, "Failure preparing request") + return + } + + result, err = client.UpdateTagsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client DdosProtectionPlansClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ddosProtectionPlanName": autorest.Encode("path", ddosProtectionPlanName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client DdosProtectionPlansClient) UpdateTagsSender(req *http.Request) (future DdosProtectionPlansUpdateTagsFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client DdosProtectionPlansClient) UpdateTagsResponder(resp *http.Response) (result DdosProtectionPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/network/mgmt/2018-11-01/network/models.go b/services/network/mgmt/2018-11-01/network/models.go index 43a8a8c1ff0b..8679ec1742d2 100644 --- a/services/network/mgmt/2018-11-01/network/models.go +++ b/services/network/mgmt/2018-11-01/network/models.go @@ -8284,6 +8284,35 @@ func (future *DdosProtectionPlansDeleteFuture) Result(client DdosProtectionPlans return } +// DdosProtectionPlansUpdateTagsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DdosProtectionPlansUpdateTagsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DdosProtectionPlansUpdateTagsFuture) Result(client DdosProtectionPlansClient) (dpp DdosProtectionPlan, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansUpdateTagsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("network.DdosProtectionPlansUpdateTagsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dpp.Response.Response, err = future.GetResult(sender); err == nil && dpp.Response.Response.StatusCode != http.StatusNoContent { + dpp, err = client.UpdateTagsResponder(dpp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansUpdateTagsFuture", "Result", dpp.Response.Response, "Failure responding to request") + } + } + return +} + // DdosSettings contains the DDoS protection settings of the public IP. type DdosSettings struct { // DdosCustomPolicy - The DDoS custom policy associated with the public IP. diff --git a/services/network/mgmt/2018-11-01/network/networkapi/interfaces.go b/services/network/mgmt/2018-11-01/network/networkapi/interfaces.go index 800393a5ad18..4101081eb453 100644 --- a/services/network/mgmt/2018-11-01/network/networkapi/interfaces.go +++ b/services/network/mgmt/2018-11-01/network/networkapi/interfaces.go @@ -114,6 +114,7 @@ type DdosProtectionPlansClientAPI interface { Get(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (result network.DdosProtectionPlan, err error) List(ctx context.Context) (result network.DdosProtectionPlanListResultPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.DdosProtectionPlanListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters network.TagsObject) (result network.DdosProtectionPlansUpdateTagsFuture, err error) } var _ DdosProtectionPlansClientAPI = (*network.DdosProtectionPlansClient)(nil) diff --git a/services/network/mgmt/2018-12-01/network/ddosprotectionplans.go b/services/network/mgmt/2018-12-01/network/ddosprotectionplans.go index 148f6d4c0a85..6d73bed504ec 100644 --- a/services/network/mgmt/2018-12-01/network/ddosprotectionplans.go +++ b/services/network/mgmt/2018-12-01/network/ddosprotectionplans.go @@ -495,3 +495,83 @@ func (client DdosProtectionPlansClient) ListByResourceGroupComplete(ctx context. result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) return } + +// UpdateTags update a DDoS protection plan tags +// Parameters: +// resourceGroupName - the name of the resource group. +// ddosProtectionPlanName - the name of the DDoS protection plan. +// parameters - parameters supplied to the update DDoS protection plan resource tags. +func (client DdosProtectionPlansClient) UpdateTags(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject) (result DdosProtectionPlansUpdateTagsFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DdosProtectionPlansClient.UpdateTags") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateTagsPreparer(ctx, resourceGroupName, ddosProtectionPlanName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", nil, "Failure preparing request") + return + } + + result, err = client.UpdateTagsSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansClient", "UpdateTags", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdateTagsPreparer prepares the UpdateTags request. +func (client DdosProtectionPlansClient) UpdateTagsPreparer(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters TagsObject) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "ddosProtectionPlanName": autorest.Encode("path", ddosProtectionPlanName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/ddosProtectionPlans/{ddosProtectionPlanName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateTagsSender sends the UpdateTags request. The method will close the +// http.Response Body if it receives an error. +func (client DdosProtectionPlansClient) UpdateTagsSender(req *http.Request) (future DdosProtectionPlansUpdateTagsFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateTagsResponder handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (client DdosProtectionPlansClient) UpdateTagsResponder(resp *http.Response) (result DdosProtectionPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/network/mgmt/2018-12-01/network/models.go b/services/network/mgmt/2018-12-01/network/models.go index 57e0bfd75296..16441c186e06 100644 --- a/services/network/mgmt/2018-12-01/network/models.go +++ b/services/network/mgmt/2018-12-01/network/models.go @@ -8470,6 +8470,35 @@ func (future *DdosProtectionPlansDeleteFuture) Result(client DdosProtectionPlans return } +// DdosProtectionPlansUpdateTagsFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DdosProtectionPlansUpdateTagsFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DdosProtectionPlansUpdateTagsFuture) Result(client DdosProtectionPlansClient) (dpp DdosProtectionPlan, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansUpdateTagsFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("network.DdosProtectionPlansUpdateTagsFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if dpp.Response.Response, err = future.GetResult(sender); err == nil && dpp.Response.Response.StatusCode != http.StatusNoContent { + dpp, err = client.UpdateTagsResponder(dpp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "network.DdosProtectionPlansUpdateTagsFuture", "Result", dpp.Response.Response, "Failure responding to request") + } + } + return +} + // DdosSettings contains the DDoS protection settings of the public IP. type DdosSettings struct { // DdosCustomPolicy - The DDoS custom policy associated with the public IP. diff --git a/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go b/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go index 9f37df5450d6..647dda053d25 100644 --- a/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go +++ b/services/network/mgmt/2018-12-01/network/networkapi/interfaces.go @@ -114,6 +114,7 @@ type DdosProtectionPlansClientAPI interface { Get(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string) (result network.DdosProtectionPlan, err error) List(ctx context.Context) (result network.DdosProtectionPlanListResultPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result network.DdosProtectionPlanListResultPage, err error) + UpdateTags(ctx context.Context, resourceGroupName string, ddosProtectionPlanName string, parameters network.TagsObject) (result network.DdosProtectionPlansUpdateTagsFuture, err error) } var _ DdosProtectionPlansClientAPI = (*network.DdosProtectionPlansClient)(nil)