From 88e6c5b3c3b60ca5ffe6bc9f2f16fe5cdad9b25c Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 9 Oct 2025 14:00:36 +0000 Subject: [PATCH] Configurations: 'specification/nginx/Nginx.Management/tspconfig.yaml', API Version: 2025-03-01-preview, SDK Release Type: beta, and CommitSHA: 'aae85aa3e7e4fda95ea2d3abac0ba1d8159db214' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=5433790 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../nginx/armnginx/CHANGELOG.md | 46 + .../nginx/armnginx/apikeys_client.go | 44 +- .../armnginx/apikeys_client_example_test.go | 106 +- .../nginx/armnginx/autorest.md | 13 - sdk/resourcemanager/nginx/armnginx/build.go | 7 - .../nginx/armnginx/certificates_client.go | 57 +- .../certificates_client_example_test.go | 175 ++-- .../nginx/armnginx/client_factory.go | 22 +- .../nginx/armnginx/configurations_client.go | 62 +- .../configurations_client_example_test.go | 237 ++--- .../nginx/armnginx/constants.go | 112 ++- .../nginx/armnginx/defaultwafpolicy_client.go | 104 ++ .../defaultwafpolicy_client_example_test.go | 43 + .../nginx/armnginx/deployments_client.go | 90 +- .../deployments_client_example_test.go | 918 +++++++++--------- .../nginx/armnginx/fake/apikeys_server.go | 86 +- .../armnginx/fake/certificates_server.go | 86 +- .../armnginx/fake/configurations_server.go | 91 +- .../armnginx/fake/defaultwafpolicy_server.go | 121 +++ .../nginx/armnginx/fake/deployments_server.go | 114 ++- .../nginx/armnginx/fake/internal.go | 11 +- .../nginx/armnginx/fake/operations_server.go | 55 +- .../nginx/armnginx/fake/server_factory.go | 53 +- .../nginx/armnginx/fake/time_rfc3339.go | 110 --- .../nginx/armnginx/fake/wafpolicy_server.go | 293 ++++++ sdk/resourcemanager/nginx/armnginx/go.mod | 22 +- sdk/resourcemanager/nginx/armnginx/go.sum | 46 +- sdk/resourcemanager/nginx/armnginx/models.go | 375 +++++-- .../nginx/armnginx/models_serde.go | 446 ++++++++- .../nginx/armnginx/operations_client.go | 14 +- .../operations_client_example_test.go | 37 +- sdk/resourcemanager/nginx/armnginx/options.go | 60 +- .../nginx/armnginx/responses.go | 50 +- .../nginx/armnginx/testdata/_metadata.json | 4 + .../nginx/armnginx/time_rfc3339.go | 9 +- .../nginx/armnginx/tsp-location.yaml | 4 + sdk/resourcemanager/nginx/armnginx/version.go | 10 + .../nginx/armnginx/wafpolicy_client.go | 338 +++++++ .../armnginx/wafpolicy_client_example_test.go | 191 ++++ 39 files changed, 3263 insertions(+), 1399 deletions(-) delete mode 100644 sdk/resourcemanager/nginx/armnginx/autorest.md delete mode 100644 sdk/resourcemanager/nginx/armnginx/build.go create mode 100644 sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client.go create mode 100644 sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client_example_test.go create mode 100644 sdk/resourcemanager/nginx/armnginx/fake/defaultwafpolicy_server.go delete mode 100644 sdk/resourcemanager/nginx/armnginx/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/nginx/armnginx/fake/wafpolicy_server.go create mode 100644 sdk/resourcemanager/nginx/armnginx/testdata/_metadata.json create mode 100644 sdk/resourcemanager/nginx/armnginx/tsp-location.yaml create mode 100644 sdk/resourcemanager/nginx/armnginx/version.go create mode 100644 sdk/resourcemanager/nginx/armnginx/wafpolicy_client.go create mode 100644 sdk/resourcemanager/nginx/armnginx/wafpolicy_client_example_test.go diff --git a/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md b/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md index 06d55e1347e8..2331b1fcf7bd 100644 --- a/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md +++ b/sdk/resourcemanager/nginx/armnginx/CHANGELOG.md @@ -1,5 +1,51 @@ # Release History +## 3.1.0-beta.3 (2025-10-09) +### Breaking Changes + +- Function `*APIKeysClient.CreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, string, *APIKeysClientCreateOrUpdateOptions)` to `(context.Context, string, string, string, DeploymentAPIKeyRequest, *APIKeysClientCreateOrUpdateOptions)` +- Function `*CertificatesClient.BeginCreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, string, *CertificatesClientBeginCreateOrUpdateOptions)` to `(context.Context, string, string, string, Certificate, *CertificatesClientBeginCreateOrUpdateOptions)` +- Function `*ConfigurationsClient.BeginCreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, string, *ConfigurationsClientBeginCreateOrUpdateOptions)` to `(context.Context, string, string, string, ConfigurationRequest, *ConfigurationsClientBeginCreateOrUpdateOptions)` +- Function `*DeploymentsClient.BeginCreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, *DeploymentsClientBeginCreateOrUpdateOptions)` to `(context.Context, string, string, Deployment, *DeploymentsClientBeginCreateOrUpdateOptions)` +- Function `*DeploymentsClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, string, *DeploymentsClientBeginUpdateOptions)` to `(context.Context, string, string, DeploymentUpdateParameters, *DeploymentsClientBeginUpdateOptions)` +- Type of `OperationListResult.Value` has been changed from `[]*OperationResult` to `[]*Operation` +- Struct `OperationResult` has been removed +- Field `Body` of struct `APIKeysClientCreateOrUpdateOptions` has been removed +- Field `Body` of struct `CertificatesClientBeginCreateOrUpdateOptions` has been removed +- Field `Body` of struct `ConfigurationsClientBeginCreateOrUpdateOptions` has been removed +- Field `Body` of struct `DeploymentsClientBeginCreateOrUpdateOptions` has been removed +- Field `Body` of struct `DeploymentsClientBeginUpdateOptions` has been removed + +### Features Added + +- New enum type `ActionType` with values `ActionTypeInternal` +- New enum type `NginxDeploymentWafPolicyApplyingStatusCode` with values `NginxDeploymentWafPolicyApplyingStatusCodeApplying`, `NginxDeploymentWafPolicyApplyingStatusCodeFailed`, `NginxDeploymentWafPolicyApplyingStatusCodeNotApplied`, `NginxDeploymentWafPolicyApplyingStatusCodeRemoving`, `NginxDeploymentWafPolicyApplyingStatusCodeSucceeded` +- New enum type `NginxDeploymentWafPolicyCompilingStatusCode` with values `NginxDeploymentWafPolicyCompilingStatusCodeFailed`, `NginxDeploymentWafPolicyCompilingStatusCodeInProgress`, `NginxDeploymentWafPolicyCompilingStatusCodeNotStarted`, `NginxDeploymentWafPolicyCompilingStatusCodeSucceeded` +- New enum type `Origin` with values `OriginSystem`, `OriginUser`, `OriginUserSystem` +- New function `*ClientFactory.NewDefaultWafPolicyClient() *DefaultWafPolicyClient` +- New function `*ClientFactory.NewWafPolicyClient() *WafPolicyClient` +- New function `NewDefaultWafPolicyClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DefaultWafPolicyClient, error)` +- New function `*DefaultWafPolicyClient.List(context.Context, string, string, *DefaultWafPolicyClientListOptions) (DefaultWafPolicyClientListResponse, error)` +- New function `NewWafPolicyClient(string, azcore.TokenCredential, *arm.ClientOptions) (*WafPolicyClient, error)` +- New function `*WafPolicyClient.BeginCreate(context.Context, string, string, string, DeploymentWafPolicy, *WafPolicyClientBeginCreateOptions) (*runtime.Poller[WafPolicyClientCreateResponse], error)` +- New function `*WafPolicyClient.BeginDelete(context.Context, string, string, string, *WafPolicyClientBeginDeleteOptions) (*runtime.Poller[WafPolicyClientDeleteResponse], error)` +- New function `*WafPolicyClient.Get(context.Context, string, string, string, *WafPolicyClientGetOptions) (WafPolicyClientGetResponse, error)` +- New function `*WafPolicyClient.NewListPager(string, string, *WafPolicyClientListOptions) *runtime.Pager[WafPolicyClientListResponse]` +- New struct `DeploymentDefaultWafPolicyListResponse` +- New struct `DeploymentDefaultWafPolicyProperties` +- New struct `DeploymentWafPolicy` +- New struct `DeploymentWafPolicyApplyingStatus` +- New struct `DeploymentWafPolicyCompilingStatus` +- New struct `DeploymentWafPolicyListResponse` +- New struct `DeploymentWafPolicyMetadata` +- New struct `DeploymentWafPolicyMetadataProperties` +- New struct `DeploymentWafPolicyProperties` +- New struct `Operation` +- New field `SystemData` in struct `DeploymentAPIKeyRequest` +- New field `SystemData` in struct `DeploymentAPIKeyResponse` +- New field `WafRelease` in struct `WebApplicationFirewallStatus` + + ## 3.1.0-beta.2 (2025-02-27) ### Breaking Changes diff --git a/sdk/resourcemanager/nginx/armnginx/apikeys_client.go b/sdk/resourcemanager/nginx/armnginx/apikeys_client.go index 5a26e1db827d..f6c326287916 100644 --- a/sdk/resourcemanager/nginx/armnginx/apikeys_client.go +++ b/sdk/resourcemanager/nginx/armnginx/apikeys_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -46,18 +42,19 @@ func NewAPIKeysClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Create or update an API Key for the Nginx deployment in order to access the dataplane API endpoint // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - apiKeyName - The resource name of the API key +// - body - The API Key object containing fields (e.g. secret text, expiration date) to upsert the key. // - options - APIKeysClientCreateOrUpdateOptions contains the optional parameters for the APIKeysClient.CreateOrUpdate method. -func (client *APIKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, options *APIKeysClientCreateOrUpdateOptions) (APIKeysClientCreateOrUpdateResponse, error) { +func (client *APIKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, body DeploymentAPIKeyRequest, options *APIKeysClientCreateOrUpdateOptions) (APIKeysClientCreateOrUpdateResponse, error) { var err error const operationName = "APIKeysClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, apiKeyName, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, apiKeyName, body, options) if err != nil { return APIKeysClientCreateOrUpdateResponse{}, err } @@ -74,7 +71,7 @@ func (client *APIKeysClient) CreateOrUpdate(ctx context.Context, resourceGroupNa } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *APIKeysClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, options *APIKeysClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *APIKeysClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, body DeploymentAPIKeyRequest, _ *APIKeysClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -97,14 +94,12 @@ func (client *APIKeysClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.Body != nil { - if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err } return req, nil } @@ -121,7 +116,7 @@ func (client *APIKeysClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Delete API key for Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - apiKeyName - The resource name of the API key @@ -148,7 +143,7 @@ func (client *APIKeysClient) Delete(ctx context.Context, resourceGroupName strin } // deleteCreateRequest creates the Delete request. -func (client *APIKeysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, options *APIKeysClientDeleteOptions) (*policy.Request, error) { +func (client *APIKeysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, _ *APIKeysClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -171,16 +166,15 @@ func (client *APIKeysClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Get the specified API Key of the given Nginx deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - apiKeyName - The resource name of the API key @@ -208,7 +202,7 @@ func (client *APIKeysClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *APIKeysClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, options *APIKeysClientGetOptions) (*policy.Request, error) { +func (client *APIKeysClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, _ *APIKeysClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys/{apiKeyName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -231,7 +225,7 @@ func (client *APIKeysClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -248,7 +242,7 @@ func (client *APIKeysClient) getHandleResponse(resp *http.Response) (APIKeysClie // NewListPager - List all API Keys of the given Nginx deployment // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - options - APIKeysClientListOptions contains the optional parameters for the APIKeysClient.NewListPager method. @@ -276,7 +270,7 @@ func (client *APIKeysClient) NewListPager(resourceGroupName string, deploymentNa } // listCreateRequest creates the List request. -func (client *APIKeysClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *APIKeysClientListOptions) (*policy.Request, error) { +func (client *APIKeysClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *APIKeysClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/apiKeys" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -295,7 +289,7 @@ func (client *APIKeysClient) listCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/nginx/armnginx/apikeys_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/apikeys_client_example_test.go index 470b1e33a188..96b3c3c85646 100644 --- a/sdk/resourcemanager/nginx/armnginx/apikeys_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/apikeys_client_example_test.go @@ -1,76 +1,77 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_CreateOrUpdate.json +// Generated from example definition: 2025-03-01-preview/ApiKeys_CreateOrUpdate.json func ExampleAPIKeysClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewAPIKeysClient().CreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "myApiKey", &armnginx.APIKeysClientCreateOrUpdateOptions{Body: nil}) + res, err := clientFactory.NewAPIKeysClient().CreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "myApiKey", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DeploymentAPIKeyResponse = armnginx.DeploymentAPIKeyResponse{ - // Name: to.Ptr("myApiKey"), - // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/apiKeys/myApiKey"), - // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ - // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-09-01T00:00:00.000Z"); return t}()), - // Hint: to.Ptr("000"), + // res = armnginx.APIKeysClientCreateOrUpdateResponse{ + // DeploymentAPIKeyResponse: &armnginx.DeploymentAPIKeyResponse{ + // Name: to.Ptr("myApiKey"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey"), + // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ + // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-09-01T00:00:00Z"); return t}()), + // Hint: to.Ptr("000"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_Delete.json +// Generated from example definition: 2025-03-01-preview/ApiKeys_Delete.json func ExampleAPIKeysClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewAPIKeysClient().Delete(ctx, "myResourceGroup", "myDeployment", "myApiKey", nil) + res, err := clientFactory.NewAPIKeysClient().Delete(ctx, "myResourceGroup", "myDeployment", "myApiKey", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.APIKeysClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_Get.json +// Generated from example definition: 2025-03-01-preview/ApiKeys_Get.json func ExampleAPIKeysClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -81,25 +82,27 @@ func ExampleAPIKeysClient_Get() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DeploymentAPIKeyResponse = armnginx.DeploymentAPIKeyResponse{ - // Name: to.Ptr("myApiKey"), - // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey"), - // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ - // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-09-01T00:00:00.000Z"); return t}()), - // Hint: to.Ptr("000"), + // res = armnginx.APIKeysClientGetResponse{ + // DeploymentAPIKeyResponse: &armnginx.DeploymentAPIKeyResponse{ + // Name: to.Ptr("myApiKey"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey"), + // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ + // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-09-01T00:00:00Z"); return t}()), + // Hint: to.Ptr("000"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/ApiKeys_List.json +// Generated from example definition: 2025-03-01-preview/ApiKeys_List.json func ExampleAPIKeysClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -114,26 +117,29 @@ func ExampleAPIKeysClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DeploymentAPIKeyListResponse = armnginx.DeploymentAPIKeyListResponse{ - // Value: []*armnginx.DeploymentAPIKeyResponse{ - // { - // Name: to.Ptr("myApiKey"), - // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey"), - // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ - // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-09-01T00:00:00.000Z"); return t}()), - // Hint: to.Ptr("000"), + // page = armnginx.APIKeysClientListResponse{ + // DeploymentAPIKeyListResponse: armnginx.DeploymentAPIKeyListResponse{ + // Value: []*armnginx.DeploymentAPIKeyResponse{ + // { + // Name: to.Ptr("myApiKey"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey"), + // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ + // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-09-01T00:00:00Z"); return t}()), + // Hint: to.Ptr("000"), + // }, // }, - // }, - // { - // Name: to.Ptr("myApiKey2"), - // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey2"), - // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ - // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-01T00:00:00.000Z"); return t}()), - // Hint: to.Ptr("111"), + // { + // Name: to.Ptr("myApiKey2"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/apiKeys"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/apiKeys/myApiKey2"), + // Properties: &armnginx.DeploymentAPIKeyResponseProperties{ + // EndDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-01T00:00:00Z"); return t}()), + // Hint: to.Ptr("111"), + // }, // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/nginx/armnginx/autorest.md b/sdk/resourcemanager/nginx/armnginx/autorest.md deleted file mode 100644 index d63c4af7fc14..000000000000 --- a/sdk/resourcemanager/nginx/armnginx/autorest.md +++ /dev/null @@ -1,13 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 3.1.0-beta.2 -tag: package-2024-11-01-preview -``` \ No newline at end of file diff --git a/sdk/resourcemanager/nginx/armnginx/build.go b/sdk/resourcemanager/nginx/armnginx/build.go deleted file mode 100644 index 4d34085b87bc..000000000000 --- a/sdk/resourcemanager/nginx/armnginx/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -removeUnreferencedTypes resourcemanager/nginx/armnginx - -package armnginx diff --git a/sdk/resourcemanager/nginx/armnginx/certificates_client.go b/sdk/resourcemanager/nginx/armnginx/certificates_client.go index eeb09f525936..8e88bb3524b1 100644 --- a/sdk/resourcemanager/nginx/armnginx/certificates_client.go +++ b/sdk/resourcemanager/nginx/armnginx/certificates_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -46,21 +42,21 @@ func NewCertificatesClient(subscriptionID string, credential azcore.TokenCredent // BeginCreateOrUpdate - Create or update the NGINX certificates for given NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - certificateName - The name of certificate +// - body - The certificate // - options - CertificatesClientBeginCreateOrUpdateOptions contains the optional parameters for the CertificatesClient.BeginCreateOrUpdate // method. -func (client *CertificatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CertificatesClientCreateOrUpdateResponse], error) { +func (client *CertificatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, body Certificate, options *CertificatesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CertificatesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, certificateName, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, certificateName, body, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CertificatesClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -73,14 +69,14 @@ func (client *CertificatesClient) BeginCreateOrUpdate(ctx context.Context, resou // CreateOrUpdate - Create or update the NGINX certificates for given NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview -func (client *CertificatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-03-01-preview +func (client *CertificatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, body Certificate, options *CertificatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "CertificatesClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, certificateName, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, certificateName, body, options) if err != nil { return nil, err } @@ -96,7 +92,7 @@ func (client *CertificatesClient) createOrUpdate(ctx context.Context, resourceGr } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *CertificatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *CertificatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, body Certificate, _ *CertificatesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -119,14 +115,12 @@ func (client *CertificatesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.Body != nil { - if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err } return req, nil } @@ -134,7 +128,7 @@ func (client *CertificatesClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Deletes a certificate from the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - certificateName - The name of certificate @@ -160,7 +154,7 @@ func (client *CertificatesClient) BeginDelete(ctx context.Context, resourceGroup // Delete - Deletes a certificate from the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview func (client *CertificatesClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "CertificatesClient.BeginDelete" @@ -175,7 +169,7 @@ func (client *CertificatesClient) deleteOperation(ctx context.Context, resourceG if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -183,7 +177,7 @@ func (client *CertificatesClient) deleteOperation(ctx context.Context, resourceG } // deleteCreateRequest creates the Delete request. -func (client *CertificatesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientBeginDeleteOptions) (*policy.Request, error) { +func (client *CertificatesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, _ *CertificatesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -206,16 +200,15 @@ func (client *CertificatesClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Get a certificate of given NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - certificateName - The name of certificate @@ -243,7 +236,7 @@ func (client *CertificatesClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *CertificatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *CertificatesClientGetOptions) (*policy.Request, error) { +func (client *CertificatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, _ *CertificatesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates/{certificateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -266,7 +259,7 @@ func (client *CertificatesClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -283,7 +276,7 @@ func (client *CertificatesClient) getHandleResponse(resp *http.Response) (Certif // NewListPager - List all certificates of given NGINX deployment // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - options - CertificatesClientListOptions contains the optional parameters for the CertificatesClient.NewListPager method. @@ -311,7 +304,7 @@ func (client *CertificatesClient) NewListPager(resourceGroupName string, deploym } // listCreateRequest creates the List request. -func (client *CertificatesClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *CertificatesClientListOptions) (*policy.Request, error) { +func (client *CertificatesClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *CertificatesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/certificates" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -330,7 +323,7 @@ func (client *CertificatesClient) listCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go index 54b4981be8ad..281a6c4bc41d 100644 --- a/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/certificates_client_example_test.go @@ -1,124 +1,122 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_Get.json -func ExampleCertificatesClient_Get() { +// Generated from example definition: 2025-03-01-preview/Certificates_CreateOrUpdate.json +func ExampleCertificatesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewCertificatesClient().Get(ctx, "myResourceGroup", "myDeployment", "default", nil) + poller, err := clientFactory.NewCertificatesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Certificate = armnginx.Certificate{ - // Name: to.Ptr("default"), - // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/default"), - // Properties: &armnginx.CertificateProperties{ - // CertificateError: &armnginx.CertificateErrorResponseBody{ - // Code: to.Ptr("CertificateNotYetValid"), - // Message: to.Ptr("The certificate is not yet valid. The certificate is not yet valid. NotBefore: '2020-01-01T00:00:00Z', NotAfter: '2020-01-01T00:00:00Z'"), + // res = armnginx.CertificatesClientCreateOrUpdateResponse{ + // Certificate: &armnginx.Certificate{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/certificates/default"), + // Properties: &armnginx.CertificateProperties{ + // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), // }, - // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), - // KeyVaultSecretCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T00:00:00.000Z"); return t}()), - // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), - // KeyVaultSecretVersion: to.Ptr("12345678ef9a12345678ef9a12345678"), - // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // SHA1Thumbprint: to.Ptr("1234567890ABCDEF1234567890ABCDEF12345678"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_CreateOrUpdate.json -func ExampleCertificatesClient_BeginCreateOrUpdate() { +// Generated from example definition: 2025-03-01-preview/Certificates_Delete.json +func ExampleCertificatesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewCertificatesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.CertificatesClientBeginCreateOrUpdateOptions{Body: nil}) + poller, err := clientFactory.NewCertificatesClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - res, err := poller.PollUntilDone(ctx, nil) + _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Certificate = armnginx.Certificate{ - // Name: to.Ptr("default"), - // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/default"), - // Properties: &armnginx.CertificateProperties{ - // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), - // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), - // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_Delete.json -func ExampleCertificatesClient_BeginDelete() { +// Generated from example definition: 2025-03-01-preview/Certificates_Get.json +func ExampleCertificatesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewCertificatesClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", "default", nil) + res, err := clientFactory.NewCertificatesClient().Get(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.CertificatesClientGetResponse{ + // Certificate: &armnginx.Certificate{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/certificates/default"), + // Properties: &armnginx.CertificateProperties{ + // CertificateError: &armnginx.CertificateErrorResponseBody{ + // Code: to.Ptr("CertificateNotYetValid"), + // Message: to.Ptr("The certificate is not yet valid. The certificate is not yet valid. NotBefore: '2020-01-01T00:00:00Z', NotAfter: '2020-01-01T00:00:00Z'"), + // }, + // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), + // KeyVaultSecretCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T00:00:00Z"); return t}()), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), + // KeyVaultSecretVersion: to.Ptr("12345678ef9a12345678ef9a12345678"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // SHA1Thumbprint: to.Ptr("1234567890ABCDEF1234567890ABCDEF12345678"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Certificates_List.json +// Generated from example definition: 2025-03-01-preview/Certificates_List.json func ExampleCertificatesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -133,40 +131,43 @@ func ExampleCertificatesClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.CertificateListResponse = armnginx.CertificateListResponse{ - // Value: []*armnginx.Certificate{ - // { - // Name: to.Ptr("cert1"), - // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/cert1"), - // Properties: &armnginx.CertificateProperties{ - // CertificateError: &armnginx.CertificateErrorResponseBody{ - // Code: to.Ptr("CertificateNotYetValid"), - // Message: to.Ptr("The certificate is not yet valid. The certificate is not yet valid. NotBefore: '2020-01-01T00:00:00Z', NotAfter: '2020-01-01T00:00:00Z'"), + // page = armnginx.CertificatesClientListResponse{ + // CertificateListResponse: armnginx.CertificateListResponse{ + // Value: []*armnginx.Certificate{ + // { + // Name: to.Ptr("cert1"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/certificates/cert1"), + // Properties: &armnginx.CertificateProperties{ + // CertificateError: &armnginx.CertificateErrorResponseBody{ + // Code: to.Ptr("CertificateNotYetValid"), + // Message: to.Ptr("The certificate is not yet valid. The certificate is not yet valid. NotBefore: '2020-01-01T00:00:00Z', NotAfter: '2020-01-01T00:00:00Z'"), + // }, + // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), + // KeyVaultSecretCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T00:00:00Z"); return t}()), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), + // KeyVaultSecretVersion: to.Ptr("12345678ef9a12345678ef9a12345678"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // SHA1Thumbprint: to.Ptr("1234567890ABCDEF1234567890ABCDEF12345678"), // }, - // CertificateVirtualPath: to.Ptr("/src/cert/somePath.cert"), - // KeyVaultSecretCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T00:00:00.000Z"); return t}()), - // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID"), - // KeyVaultSecretVersion: to.Ptr("12345678ef9a12345678ef9a12345678"), - // KeyVirtualPath: to.Ptr("/src/cert/somekey.key"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // SHA1Thumbprint: to.Ptr("1234567890ABCDEF1234567890ABCDEF12345678"), // }, - // }, - // { - // Name: to.Ptr("cert2"), - // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), - // ID: to.Ptr("/subscritions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/NGINX.NGINXPLUS/nginxDeployments/myDeployment/certificates/cert2"), - // Properties: &armnginx.CertificateProperties{ - // CertificateVirtualPath: to.Ptr("/src/cert/somePath2.cert"), - // KeyVaultSecretCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T00:00:00.000Z"); return t}()), - // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID2"), - // KeyVaultSecretVersion: to.Ptr("12345678ef9a12345678ef9a12345678"), - // KeyVirtualPath: to.Ptr("/src/cert/somekey2.key"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // SHA1Thumbprint: to.Ptr("1234567890ABCDEF1234567890ABCDEF12345678"), + // { + // Name: to.Ptr("cert2"), + // Type: to.Ptr("nginx.nginxplus/nginxdeployments/certificates"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/certificates/cert2"), + // Properties: &armnginx.CertificateProperties{ + // CertificateVirtualPath: to.Ptr("/src/cert/somePath2.cert"), + // KeyVaultSecretCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T00:00:00Z"); return t}()), + // KeyVaultSecretID: to.Ptr("https://someKV.vault.azure.com/someSecretID2"), + // KeyVaultSecretVersion: to.Ptr("12345678ef9a12345678ef9a12345678"), + // KeyVirtualPath: to.Ptr("/src/cert/somekey2.key"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // SHA1Thumbprint: to.Ptr("1234567890ABCDEF1234567890ABCDEF12345678"), + // }, // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/nginx/armnginx/client_factory.go b/sdk/resourcemanager/nginx/armnginx/client_factory.go index 93f042ea41fd..ced2b85ac58d 100644 --- a/sdk/resourcemanager/nginx/armnginx/client_factory.go +++ b/sdk/resourcemanager/nginx/armnginx/client_factory.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -60,6 +56,14 @@ func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { } } +// NewDefaultWafPolicyClient creates a new instance of DefaultWafPolicyClient. +func (c *ClientFactory) NewDefaultWafPolicyClient() *DefaultWafPolicyClient { + return &DefaultWafPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + // NewDeploymentsClient creates a new instance of DeploymentsClient. func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { return &DeploymentsClient{ @@ -74,3 +78,11 @@ func (c *ClientFactory) NewOperationsClient() *OperationsClient { internal: c.internal, } } + +// NewWafPolicyClient creates a new instance of WafPolicyClient. +func (c *ClientFactory) NewWafPolicyClient() *WafPolicyClient { + return &WafPolicyClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/nginx/armnginx/configurations_client.go b/sdk/resourcemanager/nginx/armnginx/configurations_client.go index 9324b9f1e0ef..05e7c87f3975 100644 --- a/sdk/resourcemanager/nginx/armnginx/configurations_client.go +++ b/sdk/resourcemanager/nginx/armnginx/configurations_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -46,7 +42,7 @@ func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCrede // Analysis - Analyze an NGINX configuration without applying it to the NGINXaaS deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - configurationName - The name of configuration, only 'default' is supported value due to the singleton of NGINX conf @@ -97,10 +93,11 @@ func (client *ConfigurationsClient) analysisCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { return nil, err } @@ -121,21 +118,21 @@ func (client *ConfigurationsClient) analysisHandleResponse(resp *http.Response) // BeginCreateOrUpdate - Create or update the NGINX configuration for given NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - configurationName - The name of configuration, only 'default' is supported value due to the singleton of NGINX conf +// - body - The NGINX configuration // - options - ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate // method. -func (client *ConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConfigurationsClientCreateOrUpdateResponse], error) { +func (client *ConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, body ConfigurationRequest, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConfigurationsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, configurationName, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, configurationName, body, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConfigurationsClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -148,14 +145,14 @@ func (client *ConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, res // CreateOrUpdate - Create or update the NGINX configuration for given NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview -func (client *ConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-03-01-preview +func (client *ConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, body ConfigurationRequest, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ConfigurationsClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, configurationName, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, configurationName, body, options) if err != nil { return nil, err } @@ -171,7 +168,7 @@ func (client *ConfigurationsClient) createOrUpdate(ctx context.Context, resource } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, body ConfigurationRequest, _ *ConfigurationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -194,14 +191,12 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.Body != nil { - if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err } return req, nil } @@ -209,7 +204,7 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont // BeginDelete - Reset the NGINX configuration of given NGINX deployment to default // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - configurationName - The name of configuration, only 'default' is supported value due to the singleton of NGINX conf @@ -235,7 +230,7 @@ func (client *ConfigurationsClient) BeginDelete(ctx context.Context, resourceGro // Delete - Reset the NGINX configuration of given NGINX deployment to default // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview func (client *ConfigurationsClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ConfigurationsClient.BeginDelete" @@ -250,7 +245,7 @@ func (client *ConfigurationsClient) deleteOperation(ctx context.Context, resourc if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -258,7 +253,7 @@ func (client *ConfigurationsClient) deleteOperation(ctx context.Context, resourc } // deleteCreateRequest creates the Delete request. -func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, _ *ConfigurationsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -281,16 +276,15 @@ func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Get the NGINX configuration of given NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - configurationName - The name of configuration, only 'default' is supported value due to the singleton of NGINX conf @@ -318,7 +312,7 @@ func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *ConfigurationsClientGetOptions) (*policy.Request, error) { +func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, _ *ConfigurationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations/{configurationName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -341,7 +335,7 @@ func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -358,7 +352,7 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf // NewListPager - List the NGINX configuration of given NGINX deployment. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - options - ConfigurationsClientListOptions contains the optional parameters for the ConfigurationsClient.NewListPager method. @@ -386,7 +380,7 @@ func (client *ConfigurationsClient) NewListPager(resourceGroupName string, deplo } // listCreateRequest creates the List request. -func (client *ConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *ConfigurationsClientListOptions) (*policy.Request, error) { +func (client *ConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *ConfigurationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/configurations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -405,7 +399,7 @@ func (client *ConfigurationsClient) listCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go index 2bb432ba058f..90122a4c95ca 100644 --- a/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/configurations_client_example_test.go @@ -1,124 +1,66 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_List.json -func ExampleConfigurationsClient_NewListPager() { +// Generated from example definition: 2025-03-01-preview/Configurations_Analysis.json +func ExampleConfigurationsClient_Analysis() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewConfigurationsClient().NewListPager("myResourceGroup", "myDeployment", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ConfigurationListResponse = armnginx.ConfigurationListResponse{ - // Value: []*armnginx.ConfigurationResponse{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), - // Properties: &armnginx.ConfigurationResponseProperties{ - // Files: []*armnginx.ConfigurationFile{ - // { - // Content: to.Ptr("ABCDEF=="), - // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), - // }}, - // Package: &armnginx.ConfigurationPackage{ - // }, - // ProtectedFiles: []*armnginx.ConfigurationProtectedFileResponse{ - // { - // ContentHash: to.Ptr("sha256:1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"), - // VirtualPath: to.Ptr("/etc/nginx/protected-file.cert"), - // }}, - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // RootFile: to.Ptr("/etc/nginx/nginx.conf"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_Get.json -func ExampleConfigurationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().Get(ctx, "myResourceGroup", "myDeployment", "default", nil) + res, err := clientFactory.NewConfigurationsClient().Analysis(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConfigurationResponse = armnginx.ConfigurationResponse{ - // Name: to.Ptr("default"), - // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), - // Properties: &armnginx.ConfigurationResponseProperties{ - // Files: []*armnginx.ConfigurationFile{ - // { - // Content: to.Ptr("ABCDEF=="), - // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), - // }}, - // Package: &armnginx.ConfigurationPackage{ + // res = armnginx.ConfigurationsClientAnalysisResponse{ + // AnalysisResult: &armnginx.AnalysisResult{ + // Data: &armnginx.AnalysisResultData{ + // Errors: []*armnginx.AnalysisDiagnostic{ + // { + // Description: to.Ptr("Directives outside the http context are not allowed"), + // Directive: to.Ptr("worker_processes"), + // File: to.Ptr("/etc/nginx/nginx.conf"), + // ID: to.Ptr("config-analysis-error-1"), + // Line: to.Ptr[float32](2), + // Message: to.Ptr("You are not allowed to set the worker_processes directive"), + // Rule: to.Ptr("nginx-azure-load-balancer-allowed-directives"), + // }, + // }, // }, - // ProtectedFiles: []*armnginx.ConfigurationProtectedFileResponse{ - // { - // ContentHash: to.Ptr("sha256:1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"), - // VirtualPath: to.Ptr("/etc/nginx/protected-file.cert"), - // }}, - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // RootFile: to.Ptr("/etc/nginx/nginx.conf"), + // Status: to.Ptr("FAILED"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_CreateOrUpdate.json +// Generated from example definition: 2025-03-01-preview/Configurations_CreateOrUpdate.json func ExampleConfigurationsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewConfigurationsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.ConfigurationsClientBeginCreateOrUpdateOptions{Body: nil}) + poller, err := clientFactory.NewConfigurationsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -129,32 +71,35 @@ func ExampleConfigurationsClient_BeginCreateOrUpdate() { // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ConfigurationResponse = armnginx.ConfigurationResponse{ - // Name: to.Ptr("default"), - // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), - // Properties: &armnginx.ConfigurationResponseProperties{ - // Files: []*armnginx.ConfigurationFile{ - // { - // Content: to.Ptr("ABCDEF=="), - // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), - // }}, - // Package: &armnginx.ConfigurationPackage{ + // res = armnginx.ConfigurationsClientCreateOrUpdateResponse{ + // ConfigurationResponse: &armnginx.ConfigurationResponse{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), + // Properties: &armnginx.ConfigurationResponseProperties{ + // Files: []*armnginx.ConfigurationFile{ + // { + // Content: to.Ptr("ABCDEF=="), + // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // }, + // Package: &armnginx.ConfigurationPackage{ + // }, + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // RootFile: to.Ptr("/etc/nginx/nginx.conf"), // }, - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // RootFile: to.Ptr("/etc/nginx/nginx.conf"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_Delete.json +// Generated from example definition: 2025-03-01-preview/Configurations_Delete.json func ExampleConfigurationsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -168,37 +113,101 @@ func ExampleConfigurationsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Configurations_Analysis.json -func ExampleConfigurationsClient_Analysis() { +// Generated from example definition: 2025-03-01-preview/Configurations_Get.json +func ExampleConfigurationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewConfigurationsClient().Analysis(ctx, "myResourceGroup", "myDeployment", "default", &armnginx.ConfigurationsClientAnalysisOptions{Body: nil}) + res, err := clientFactory.NewConfigurationsClient().Get(ctx, "myResourceGroup", "myDeployment", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AnalysisResult = armnginx.AnalysisResult{ - // Data: &armnginx.AnalysisResultData{ - // Errors: []*armnginx.AnalysisDiagnostic{ - // { - // Description: to.Ptr("Directives outside the http context are not allowed"), - // Directive: to.Ptr("worker_processes"), - // File: to.Ptr("/etc/nginx/nginx.conf"), - // ID: to.Ptr("config-analysis-error-1"), - // Line: to.Ptr[float32](2), - // Message: to.Ptr("You are not allowed to set the worker_processes directive"), - // Rule: to.Ptr("nginx-azure-load-balancer-allowed-directives"), - // }}, + // res = armnginx.ConfigurationsClientGetResponse{ + // ConfigurationResponse: &armnginx.ConfigurationResponse{ + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), + // Properties: &armnginx.ConfigurationResponseProperties{ + // Files: []*armnginx.ConfigurationFile{ + // { + // Content: to.Ptr("ABCDEF=="), + // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // }, + // Package: &armnginx.ConfigurationPackage{ + // }, + // ProtectedFiles: []*armnginx.ConfigurationProtectedFileResponse{ + // { + // ContentHash: to.Ptr("sha256:1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"), + // VirtualPath: to.Ptr("/etc/nginx/protected-file.cert"), + // }, + // }, + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // RootFile: to.Ptr("/etc/nginx/nginx.conf"), + // }, // }, - // Status: to.Ptr("FAILED"), // } } + +// Generated from example definition: 2025-03-01-preview/Configurations_List.json +func ExampleConfigurationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewConfigurationsClient().NewListPager("myResourceGroup", "myDeployment", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armnginx.ConfigurationsClientListResponse{ + // ConfigurationListResponse: armnginx.ConfigurationListResponse{ + // Value: []*armnginx.ConfigurationResponse{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("nginx.nginxplus/nginxDeployments/configurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/configurations/default"), + // Properties: &armnginx.ConfigurationResponseProperties{ + // Files: []*armnginx.ConfigurationFile{ + // { + // Content: to.Ptr("ABCDEF=="), + // VirtualPath: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // }, + // Package: &armnginx.ConfigurationPackage{ + // }, + // ProtectedFiles: []*armnginx.ConfigurationProtectedFileResponse{ + // { + // ContentHash: to.Ptr("sha256:1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"), + // VirtualPath: to.Ptr("/etc/nginx/protected-file.cert"), + // }, + // }, + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // RootFile: to.Ptr("/etc/nginx/nginx.conf"), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/sdk/resourcemanager/nginx/armnginx/constants.go b/sdk/resourcemanager/nginx/armnginx/constants.go index 15032c4bae7c..c67e544bd583 100644 --- a/sdk/resourcemanager/nginx/armnginx/constants.go +++ b/sdk/resourcemanager/nginx/armnginx/constants.go @@ -1,18 +1,24 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + const ( - moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx" - moduleVersion = "v3.1.0-beta.2" + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" ) +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + // ActivationState - The activation state of the WAF. Use 'Enabled' to enable the WAF and 'Disabled' to disable it. type ActivationState string @@ -29,14 +35,18 @@ func PossibleActivationStateValues() []ActivationState { } } -// CreatedByType - The type of identity that created the resource. +// CreatedByType - The kind of entity that created the resource. type CreatedByType string const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) // PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. @@ -49,6 +59,7 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// IdentityType - Identity Type type IdentityType string const ( @@ -84,6 +95,62 @@ func PossibleLevelValues() []Level { } } +// NginxDeploymentWafPolicyApplyingStatusCode - Machine readable code indicating the applying status code of a WAF Policy. +type NginxDeploymentWafPolicyApplyingStatusCode string + +const ( + // NginxDeploymentWafPolicyApplyingStatusCodeApplying - The policy is referenced in the nginx config and is applying. + NginxDeploymentWafPolicyApplyingStatusCodeApplying NginxDeploymentWafPolicyApplyingStatusCode = "Applying" + // NginxDeploymentWafPolicyApplyingStatusCodeFailed - The policy is referenced in the nginx config and that config failed + // to apply. + NginxDeploymentWafPolicyApplyingStatusCodeFailed NginxDeploymentWafPolicyApplyingStatusCode = "Failed" + // NginxDeploymentWafPolicyApplyingStatusCodeNotApplied - The policy is not referenced in the nginx config and not applied. + NginxDeploymentWafPolicyApplyingStatusCodeNotApplied NginxDeploymentWafPolicyApplyingStatusCode = "NotApplied" + // NginxDeploymentWafPolicyApplyingStatusCodeRemoving - The policy is now not referenced in the nginx config and its being + // removed from the applied nginx config. + NginxDeploymentWafPolicyApplyingStatusCodeRemoving NginxDeploymentWafPolicyApplyingStatusCode = "Removing" + // NginxDeploymentWafPolicyApplyingStatusCodeSucceeded - The policy is referenced in the nginx config and that config has + // been successfully applied. + NginxDeploymentWafPolicyApplyingStatusCodeSucceeded NginxDeploymentWafPolicyApplyingStatusCode = "Succeeded" +) + +// PossibleNginxDeploymentWafPolicyApplyingStatusCodeValues returns the possible values for the NginxDeploymentWafPolicyApplyingStatusCode const type. +func PossibleNginxDeploymentWafPolicyApplyingStatusCodeValues() []NginxDeploymentWafPolicyApplyingStatusCode { + return []NginxDeploymentWafPolicyApplyingStatusCode{ + NginxDeploymentWafPolicyApplyingStatusCodeApplying, + NginxDeploymentWafPolicyApplyingStatusCodeFailed, + NginxDeploymentWafPolicyApplyingStatusCodeNotApplied, + NginxDeploymentWafPolicyApplyingStatusCodeRemoving, + NginxDeploymentWafPolicyApplyingStatusCodeSucceeded, + } +} + +// NginxDeploymentWafPolicyCompilingStatusCode - Machine readable code indicating the compilation status of a WAF Policy. +type NginxDeploymentWafPolicyCompilingStatusCode string + +const ( + // NginxDeploymentWafPolicyCompilingStatusCodeFailed - The compilation of the custom waf policy failed. + NginxDeploymentWafPolicyCompilingStatusCodeFailed NginxDeploymentWafPolicyCompilingStatusCode = "Failed" + // NginxDeploymentWafPolicyCompilingStatusCodeInProgress - The compilation of the custom waf policy is in progress + NginxDeploymentWafPolicyCompilingStatusCodeInProgress NginxDeploymentWafPolicyCompilingStatusCode = "InProgress" + // NginxDeploymentWafPolicyCompilingStatusCodeNotStarted - The compilation of the custom waf policy has not started + NginxDeploymentWafPolicyCompilingStatusCodeNotStarted NginxDeploymentWafPolicyCompilingStatusCode = "NotStarted" + // NginxDeploymentWafPolicyCompilingStatusCodeSucceeded - The compilation of the custom waf policy is completed successfully + // and can now be referenced in the nginx config. + NginxDeploymentWafPolicyCompilingStatusCodeSucceeded NginxDeploymentWafPolicyCompilingStatusCode = "Succeeded" +) + +// PossibleNginxDeploymentWafPolicyCompilingStatusCodeValues returns the possible values for the NginxDeploymentWafPolicyCompilingStatusCode const type. +func PossibleNginxDeploymentWafPolicyCompilingStatusCodeValues() []NginxDeploymentWafPolicyCompilingStatusCode { + return []NginxDeploymentWafPolicyCompilingStatusCode{ + NginxDeploymentWafPolicyCompilingStatusCodeFailed, + NginxDeploymentWafPolicyCompilingStatusCodeInProgress, + NginxDeploymentWafPolicyCompilingStatusCodeNotStarted, + NginxDeploymentWafPolicyCompilingStatusCodeSucceeded, + } +} + +// NginxPrivateIPAllocationMethod - Nginx Private IP Allocation Method type NginxPrivateIPAllocationMethod string const ( @@ -99,6 +166,29 @@ func PossibleNginxPrivateIPAllocationMethodValues() []NginxPrivateIPAllocationMe } } +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + // OriginSystem - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - Provisioning State type ProvisioningState string const ( diff --git a/sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client.go b/sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client.go new file mode 100644 index 000000000000..8d66104b4dd9 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client.go @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armnginx + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DefaultWafPolicyClient contains the methods for the DefaultWafPolicy group. +// Don't use this type directly, use NewDefaultWafPolicyClient() instead. +type DefaultWafPolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDefaultWafPolicyClient creates a new instance of DefaultWafPolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDefaultWafPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefaultWafPolicyClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DefaultWafPolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// List - Get the Nginx Waf Policy of given Nginx deployment +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted NGINX deployment +// - options - DefaultWafPolicyClientListOptions contains the optional parameters for the DefaultWafPolicyClient.List method. +func (client *DefaultWafPolicyClient) List(ctx context.Context, resourceGroupName string, deploymentName string, options *DefaultWafPolicyClientListOptions) (DefaultWafPolicyClientListResponse, error) { + var err error + const operationName = "DefaultWafPolicyClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listCreateRequest(ctx, resourceGroupName, deploymentName, options) + if err != nil { + return DefaultWafPolicyClientListResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefaultWafPolicyClientListResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefaultWafPolicyClientListResponse{}, err + } + resp, err := client.listHandleResponse(httpResp) + return resp, err +} + +// listCreateRequest creates the List request. +func (client *DefaultWafPolicyClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *DefaultWafPolicyClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/listDefaultWafPolicies" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DefaultWafPolicyClient) listHandleResponse(resp *http.Response) (DefaultWafPolicyClientListResponse, error) { + result := DefaultWafPolicyClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentDefaultWafPolicyListResponse); err != nil { + return DefaultWafPolicyClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client_example_test.go new file mode 100644 index 000000000000..5f8d3b9166a7 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/defaultwafpolicy_client_example_test.go @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armnginx_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" +) + +// Generated from example definition: 2025-03-01-preview/DefaultWafPolicy_List.json +func ExampleDefaultWafPolicyClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDefaultWafPolicyClient().List(ctx, "myResourceGroup", "myDeployment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.DefaultWafPolicyClientListResponse{ + // DeploymentDefaultWafPolicyListResponse: &armnginx.DeploymentDefaultWafPolicyListResponse{ + // NextLink: to.Ptr("https://management.azure.com/...&$skiptoken=..."), + // Value: []*armnginx.DeploymentDefaultWafPolicyProperties{ + // { + // Content: []byte("QUJDREVGR0g="), + // Filepath: to.Ptr("/etc/nginx/waf/policy.conf"), + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/nginx/armnginx/deployments_client.go b/sdk/resourcemanager/nginx/armnginx/deployments_client.go index 12e1ce3b1365..77a36ba520e8 100644 --- a/sdk/resourcemanager/nginx/armnginx/deployments_client.go +++ b/sdk/resourcemanager/nginx/armnginx/deployments_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -46,20 +42,20 @@ func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredenti // BeginCreateOrUpdate - Create or update the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment +// - body - The Nginx deployment // - options - DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate // method. -func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateResponse], error) { +func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, body Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, body, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -72,14 +68,14 @@ func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resour // CreateOrUpdate - Create or update the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview -func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-03-01-preview +func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, body Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deploymentName, body, options) if err != nil { return nil, err } @@ -95,7 +91,7 @@ func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGro } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, body Deployment, _ *DeploymentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -114,14 +110,12 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.Body != nil { - if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err } return req, nil } @@ -129,7 +123,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context // BeginDelete - Delete the NGINX deployment resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - options - DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. @@ -153,7 +147,7 @@ func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupN // Delete - Delete the NGINX deployment resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDelete" @@ -168,7 +162,7 @@ func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGr if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -176,7 +170,7 @@ func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGr } // deleteCreateRequest creates the Delete request. -func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *DeploymentsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -195,16 +189,15 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Get the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment // - options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. @@ -231,7 +224,7 @@ func (client *DeploymentsClient) Get(ctx context.Context, resourceGroupName stri } // getCreateRequest creates the Get request. -func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientGetOptions) (*policy.Request, error) { +func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *DeploymentsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -250,7 +243,7 @@ func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -267,7 +260,7 @@ func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (Deploym // NewListPager - List the NGINX deployments resources // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - options - DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.NewListPager method. func (client *DeploymentsClient) NewListPager(options *DeploymentsClientListOptions) *runtime.Pager[DeploymentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListResponse]{ @@ -293,7 +286,7 @@ func (client *DeploymentsClient) NewListPager(options *DeploymentsClientListOpti } // listCreateRequest creates the List request. -func (client *DeploymentsClient) listCreateRequest(ctx context.Context, options *DeploymentsClientListOptions) (*policy.Request, error) { +func (client *DeploymentsClient) listCreateRequest(ctx context.Context, _ *DeploymentsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Nginx.NginxPlus/nginxDeployments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -304,7 +297,7 @@ func (client *DeploymentsClient) listCreateRequest(ctx context.Context, options return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -321,7 +314,7 @@ func (client *DeploymentsClient) listHandleResponse(resp *http.Response) (Deploy // NewListByResourceGroupPager - List all NGINX deployments under the specified resource group. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByResourceGroupPager // method. @@ -349,7 +342,7 @@ func (client *DeploymentsClient) NewListByResourceGroupPager(resourceGroupName s } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DeploymentsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *DeploymentsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -364,7 +357,7 @@ func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -382,13 +375,14 @@ func (client *DeploymentsClient) listByResourceGroupHandleResponse(resp *http.Re // BeginUpdate - Update the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of targeted NGINX deployment +// - body - The Nginx deployment update parameters // - options - DeploymentsClientBeginUpdateOptions contains the optional parameters for the DeploymentsClient.BeginUpdate method. -func (client *DeploymentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginUpdateOptions) (*runtime.Poller[DeploymentsClientUpdateResponse], error) { +func (client *DeploymentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, deploymentName string, body DeploymentUpdateParameters, options *DeploymentsClientBeginUpdateOptions) (*runtime.Poller[DeploymentsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, deploymentName, options) + resp, err := client.update(ctx, resourceGroupName, deploymentName, body, options) if err != nil { return nil, err } @@ -406,14 +400,14 @@ func (client *DeploymentsClient) BeginUpdate(ctx context.Context, resourceGroupN // Update - Update the NGINX deployment // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01-preview -func (client *DeploymentsClient) update(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-03-01-preview +func (client *DeploymentsClient) update(ctx context.Context, resourceGroupName string, deploymentName string, body DeploymentUpdateParameters, options *DeploymentsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, deploymentName, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, deploymentName, body, options) if err != nil { return nil, err } @@ -421,7 +415,7 @@ func (client *DeploymentsClient) update(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -429,7 +423,7 @@ func (client *DeploymentsClient) update(ctx context.Context, resourceGroupName s } // updateCreateRequest creates the Update request. -func (client *DeploymentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginUpdateOptions) (*policy.Request, error) { +func (client *DeploymentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, body DeploymentUpdateParameters, _ *DeploymentsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -448,14 +442,12 @@ func (client *DeploymentsClient) updateCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if options != nil && options.Body != nil { - if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { - return nil, err - } - return req, nil + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err } return req, nil } diff --git a/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go index 31fd36db0099..e7b200fb2732 100644 --- a/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/deployments_client_example_test.go @@ -1,453 +1,288 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Get.json -func ExampleDeploymentsClient_Get_deploymentsGet() { +// Generated from example definition: 2025-03-01-preview/Deployments_Create.json +func ExampleDeploymentsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewDeploymentsClient().Get(ctx, "myResourceGroup", "myDeployment", nil) + poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Deployment = armnginx.Deployment{ - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // { - // PrivateIPAddress: to.Ptr("1.1.1.1"), - // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }}, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, - // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // res = armnginx.DeploymentsClientCreateOrUpdateResponse{ + // Deployment: &armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), // }, - // }, - // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ - // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ - // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), - // }, - // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ - // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.21"), + // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), + // IPAddress: to.Ptr("1.1.1.1"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, // }, - // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.22"), + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), // }, - // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ - // WafEngineVersion: to.Ptr("10.624.0"), - // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ + // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ + // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), // }, - // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.23"), + // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ + // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.21"), + // }, + // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.22"), + // }, + // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ + // WafEngineVersion: to.Ptr("10.624.0"), + // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.23"), + // }, // }, // }, - // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // Capacity: to.Ptr[int32](10), - // }, - // UserProfile: &armnginx.DeploymentUserProfile{ - // PreferredEmail: to.Ptr("example@example.email"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Get_AutoScale.json -func ExampleDeploymentsClient_Get_deploymentsGetAutoScale() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeploymentsClient().Get(ctx, "myResourceGroup", "myDeployment", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Deployment = armnginx.Deployment{ - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // { - // PrivateIPAddress: to.Ptr("1.1.1.1"), - // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }}, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, - // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // Capacity: to.Ptr[int32](10), // }, // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // AutoScaleSettings: &armnginx.DeploymentScalingPropertiesAutoScaleSettings{ - // Profiles: []*armnginx.ScaleProfile{ - // { - // Name: to.Ptr("ExampleProfile"), - // Capacity: &armnginx.ScaleProfileCapacity{ - // Max: to.Ptr[int32](50), - // Min: to.Ptr[int32](10), - // }, - // }}, - // }, - // }, - // UserProfile: &armnginx.DeploymentUserProfile{ - // PreferredEmail: to.Ptr("example@example.email"), + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Create.json -func ExampleDeploymentsClient_BeginCreateOrUpdate() { +// Generated from example definition: 2025-03-01-preview/Deployments_Delete.json +func ExampleDeploymentsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginCreateOrUpdateOptions{Body: nil}) + poller, err := clientFactory.NewDeploymentsClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - res, err := poller.PollUntilDone(ctx, nil) + _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Deployment = armnginx.Deployment{ - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), - // IPAddress: to.Ptr("1.1.1.1"), - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // { - // PrivateIPAddress: to.Ptr("1.1.1.1"), - // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }}, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, - // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }, - // }, - // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ - // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ - // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), - // }, - // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ - // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.21"), - // }, - // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.22"), - // }, - // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ - // WafEngineVersion: to.Ptr("10.624.0"), - // WafNginxVersion: to.Ptr("4.815.0"), - // }, - // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.23"), - // }, - // }, - // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // Capacity: to.Ptr[int32](10), - // }, - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Update.json -func ExampleDeploymentsClient_BeginUpdate_deploymentsUpdate() { +// Generated from example definition: 2025-03-01-preview/Deployments_Get.json +func ExampleDeploymentsClient_Get_deploymentsGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewDeploymentsClient().BeginUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginUpdateOptions{Body: nil}) + res, err := clientFactory.NewDeploymentsClient().Get(ctx, "myResourceGroup", "myDeployment", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Deployment = armnginx.Deployment{ - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), - // IPAddress: to.Ptr("1.1.1.1"), - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // { - // PrivateIPAddress: to.Ptr("1.1.1.1"), - // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }}, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, - // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // res = armnginx.DeploymentsClientGetResponse{ + // Deployment: &armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), // }, - // }, - // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ - // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ - // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), - // }, - // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ - // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.21"), + // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, // }, - // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.22"), + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), // }, - // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ - // WafEngineVersion: to.Ptr("10.624.0"), - // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ + // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ + // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), // }, - // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.23"), + // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ + // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.21"), + // }, + // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.22"), + // }, + // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ + // WafEngineVersion: to.Ptr("10.624.0"), + // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.23"), + // }, // }, // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // Capacity: to.Ptr[int32](10), + // }, + // UserProfile: &armnginx.DeploymentUserProfile{ + // PreferredEmail: to.Ptr("example@example.email"), + // }, // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // Capacity: to.Ptr[int32](10), - // }, - // UserProfile: &armnginx.DeploymentUserProfile{ - // PreferredEmail: to.Ptr("example@example.email"), - // }, - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_UpdateSubnet.json -func ExampleDeploymentsClient_BeginUpdate_deploymentsUpdateSubnet() { +// Generated from example definition: 2025-03-01-preview/Deployments_Get_AutoScale.json +func ExampleDeploymentsClient_Get_deploymentsGetAutoScale() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewDeploymentsClient().BeginUpdate(ctx, "myResourceGroup", "myDeployment", &armnginx.DeploymentsClientBeginUpdateOptions{Body: nil}) + res, err := clientFactory.NewDeploymentsClient().Get(ctx, "myResourceGroup", "myDeployment", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } // You could use response here. We use blank identifier for just demo purposes. _ = res // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Deployment = armnginx.Deployment{ - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), - // IPAddress: to.Ptr("1.1.1.1"), - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // }, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, - // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet2/subnets/mySubnet"), + // res = armnginx.DeploymentsClientGetResponse{ + // Deployment: &armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), // }, - // }, - // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ - // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ - // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), - // }, - // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ - // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.21"), - // }, - // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.22"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, // }, - // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ - // WafEngineVersion: to.Ptr("10.624.0"), - // WafNginxVersion: to.Ptr("4.815.0"), + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), // }, - // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.23"), + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // AutoScaleSettings: &armnginx.DeploymentScalingPropertiesAutoScaleSettings{ + // Profiles: []*armnginx.ScaleProfile{ + // { + // Name: to.Ptr("ExampleProfile"), + // Capacity: &armnginx.ScaleProfileCapacity{ + // Max: to.Ptr[int32](50), + // Min: to.Ptr[int32](10), + // }, + // }, + // }, // }, // }, + // UserProfile: &armnginx.DeploymentUserProfile{ + // PreferredEmail: to.Ptr("example@example.email"), + // }, // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // Capacity: to.Ptr[int32](10), - // }, - // UserProfile: &armnginx.DeploymentUserProfile{ - // PreferredEmail: to.Ptr("example@example.email"), - // }, - // }, - // Tags: map[string]*string{ - // "Environment": to.Ptr("Dev"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_Delete.json -func ExampleDeploymentsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_List.json +// Generated from example definition: 2025-03-01-preview/Deployments_List.json func ExampleDeploymentsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -462,78 +297,83 @@ func ExampleDeploymentsClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DeploymentListResponse = armnginx.DeploymentListResponse{ - // Value: []*armnginx.Deployment{ - // { - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), - // IPAddress: to.Ptr("1.1.1.1"), - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // { - // PrivateIPAddress: to.Ptr("1.1.1.1"), - // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }}, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, - // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }, - // }, - // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ - // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ - // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), + // page = armnginx.DeploymentsClientListResponse{ + // DeploymentListResponse: armnginx.DeploymentListResponse{ + // Value: []*armnginx.Deployment{ + // { + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), // }, - // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ - // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.21"), + // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), + // IPAddress: to.Ptr("1.1.1.1"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, // }, - // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.22"), + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), // }, - // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ - // WafEngineVersion: to.Ptr("10.624.0"), - // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ + // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ + // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), // }, - // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.23"), + // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ + // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.21"), + // }, + // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.22"), + // }, + // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ + // WafEngineVersion: to.Ptr("10.624.0"), + // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.23"), + // }, // }, // }, - // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // Capacity: to.Ptr[int32](10), + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // Capacity: to.Ptr[int32](10), + // }, // }, // }, - // }}, + // }, + // }, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Deployments_ListByResourceGroup.json +// Generated from example definition: 2025-03-01-preview/Deployments_ListByResourceGroup.json func ExampleDeploymentsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -548,66 +388,250 @@ func ExampleDeploymentsClient_NewListByResourceGroupPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DeploymentListResponse = armnginx.DeploymentListResponse{ - // Value: []*armnginx.Deployment{ - // { - // Name: to.Ptr("myDeployment"), - // Type: to.Ptr("nginx.nginxplus/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), - // Location: to.Ptr("westus"), - // Properties: &armnginx.DeploymentProperties{ - // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ - // UpgradeChannel: to.Ptr("stable"), - // }, - // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), - // IPAddress: to.Ptr("1.1.1.1"), - // NetworkProfile: &armnginx.NetworkProfile{ - // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ - // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ - // { - // PrivateIPAddress: to.Ptr("1.1.1.1"), - // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }}, - // PublicIPAddresses: []*armnginx.PublicIPAddress{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), - // }}, + // page = armnginx.DeploymentsClientListByResourceGroupResponse{ + // DeploymentListResponse: armnginx.DeploymentListResponse{ + // Value: []*armnginx.Deployment{ + // { + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), // }, - // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ - // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - // }, - // }, - // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ - // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ - // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), - // }, - // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ - // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.21"), + // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), + // IPAddress: to.Ptr("1.1.1.1"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, // }, - // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.22"), + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), // }, - // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ - // WafEngineVersion: to.Ptr("10.624.0"), - // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ + // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ + // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), // }, - // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ - // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53.000Z"); return t}()), - // Version: to.Ptr("2024.02.23"), + // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ + // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.21"), + // }, + // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.22"), + // }, + // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ + // WafEngineVersion: to.Ptr("10.624.0"), + // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.23"), + // }, // }, // }, - // }, - // NginxVersion: to.Ptr("nginx-1.19.6"), - // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), - // ScalingProperties: &armnginx.DeploymentScalingProperties{ - // Capacity: to.Ptr[int32](10), + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // Capacity: to.Ptr[int32](10), + // }, // }, // }, - // }}, + // }, + // }, // } } } + +// Generated from example definition: 2025-03-01-preview/Deployments_Update.json +func ExampleDeploymentsClient_BeginUpdate_deploymentsUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDeploymentsClient().BeginUpdate(ctx, "myResourceGroup", "myDeployment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.DeploymentsClientUpdateResponse{ + // Deployment: &armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), + // }, + // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), + // IPAddress: to.Ptr("1.1.1.1"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // { + // PrivateIPAddress: to.Ptr("1.1.1.1"), + // PrivateIPAllocationMethod: to.Ptr(armnginx.NginxPrivateIPAllocationMethodStatic), + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // }, + // }, + // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ + // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ + // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), + // }, + // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ + // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.21"), + // }, + // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.22"), + // }, + // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ + // WafEngineVersion: to.Ptr("10.624.0"), + // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.23"), + // }, + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // Capacity: to.Ptr[int32](10), + // }, + // UserProfile: &armnginx.DeploymentUserProfile{ + // PreferredEmail: to.Ptr("example@example.email"), + // }, + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/Deployments_UpdateSubnet.json +func ExampleDeploymentsClient_BeginUpdate_deploymentsUpdateSubnet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDeploymentsClient().BeginUpdate(ctx, "myResourceGroup", "myDeployment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.DeploymentsClientUpdateResponse{ + // Deployment: &armnginx.Deployment{ + // Name: to.Ptr("myDeployment"), + // Type: to.Ptr("nginx.nginxplus/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment"), + // Location: to.Ptr("westus"), + // Properties: &armnginx.DeploymentProperties{ + // AutoUpgradeProfile: &armnginx.AutoUpgradeProfile{ + // UpgradeChannel: to.Ptr("stable"), + // }, + // DataplaneAPIEndpoint: to.Ptr("mynginx-75b3bf22a555.eastus2.nginxaas.net"), + // IPAddress: to.Ptr("1.1.1.1"), + // NetworkProfile: &armnginx.NetworkProfile{ + // FrontEndIPConfiguration: &armnginx.FrontendIPConfiguration{ + // PrivateIPAddresses: []*armnginx.PrivateIPAddress{ + // }, + // PublicIPAddresses: []*armnginx.PublicIPAddress{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/publicIPAddresses/myPublicIPAddress"), + // }, + // }, + // }, + // NetworkInterfaceConfiguration: &armnginx.NetworkInterfaceConfiguration{ + // SubnetID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet2/subnets/mySubnet"), + // }, + // }, + // NginxAppProtect: &armnginx.DeploymentPropertiesNginxAppProtect{ + // WebApplicationFirewallSettings: &armnginx.WebApplicationFirewallSettings{ + // ActivationState: to.Ptr(armnginx.ActivationStateEnabled), + // }, + // WebApplicationFirewallStatus: &armnginx.WebApplicationFirewallStatus{ + // AttackSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-21T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.21"), + // }, + // BotSignaturesPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-22T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.22"), + // }, + // ComponentVersions: &armnginx.WebApplicationFirewallComponentVersions{ + // WafEngineVersion: to.Ptr("10.624.0"), + // WafNginxVersion: to.Ptr("4.815.0"), + // }, + // ThreatCampaignsPackage: &armnginx.WebApplicationFirewallPackage{ + // RevisionDatetime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-02-23T15:50:53Z"); return t}()), + // Version: to.Ptr("2024.02.23"), + // }, + // }, + // }, + // NginxVersion: to.Ptr("nginx-1.19.6"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // ScalingProperties: &armnginx.DeploymentScalingProperties{ + // Capacity: to.Ptr[int32](10), + // }, + // UserProfile: &armnginx.DeploymentUserProfile{ + // PreferredEmail: to.Ptr("example@example.email"), + // }, + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/apikeys_server.go b/sdk/resourcemanager/nginx/armnginx/fake/apikeys_server.go index 275abff146ce..de201a94f5b1 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/apikeys_server.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/apikeys_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,7 +15,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" "net/http" "net/url" - "reflect" "regexp" ) @@ -27,7 +22,7 @@ import ( type APIKeysServer struct { // CreateOrUpdate is the fake for method APIKeysClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, options *armnginx.APIKeysClientCreateOrUpdateOptions) (resp azfake.Responder[armnginx.APIKeysClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, apiKeyName string, body armnginx.DeploymentAPIKeyRequest, options *armnginx.APIKeysClientCreateOrUpdateOptions) (resp azfake.Responder[armnginx.APIKeysClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method APIKeysClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -67,27 +62,46 @@ func (a *APIKeysServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "APIKeysClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "APIKeysClient.Delete": - resp, err = a.dispatchDelete(req) - case "APIKeysClient.Get": - resp, err = a.dispatchGet(req) - case "APIKeysClient.NewListPager": - resp, err = a.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *APIKeysServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if apiKeysServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiKeysServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIKeysClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "APIKeysClient.Delete": + res.resp, res.err = a.dispatchDelete(req) + case "APIKeysClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "APIKeysClient.NewListPager": + res.resp, res.err = a.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *APIKeysServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -97,7 +111,7 @@ func (a *APIKeysServerTransport) dispatchCreateOrUpdate(req *http.Request) (*htt const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiKeys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armnginx.DeploymentAPIKeyRequest](req) @@ -116,13 +130,7 @@ func (a *APIKeysServerTransport) dispatchCreateOrUpdate(req *http.Request) (*htt if err != nil { return nil, err } - var options *armnginx.APIKeysClientCreateOrUpdateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armnginx.APIKeysClientCreateOrUpdateOptions{ - Body: &body, - } - } - respr, errRespr := a.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, apiKeyNameParam, options) + respr, errRespr := a.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, apiKeyNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -144,7 +152,7 @@ func (a *APIKeysServerTransport) dispatchDelete(req *http.Request) (*http.Respon const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiKeys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -181,7 +189,7 @@ func (a *APIKeysServerTransport) dispatchGet(req *http.Request) (*http.Response, const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiKeys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -220,7 +228,7 @@ func (a *APIKeysServerTransport) dispatchNewListPager(req *http.Request) (*http. const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiKeys` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -251,3 +259,9 @@ func (a *APIKeysServerTransport) dispatchNewListPager(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to APIKeysServerTransport +var apiKeysServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/certificates_server.go b/sdk/resourcemanager/nginx/armnginx/fake/certificates_server.go index e11feb3c142a..d7f0c691046c 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/certificates_server.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/certificates_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,7 +15,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" "net/http" "net/url" - "reflect" "regexp" ) @@ -27,7 +22,7 @@ import ( type CertificatesServer struct { // BeginCreateOrUpdate is the fake for method CertificatesClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, options *armnginx.CertificatesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnginx.CertificatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, certificateName string, body armnginx.Certificate, options *armnginx.CertificatesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnginx.CertificatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method CertificatesClient.BeginDelete // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent @@ -71,27 +66,46 @@ func (c *CertificatesServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "CertificatesClient.BeginCreateOrUpdate": - resp, err = c.dispatchBeginCreateOrUpdate(req) - case "CertificatesClient.BeginDelete": - resp, err = c.dispatchBeginDelete(req) - case "CertificatesClient.Get": - resp, err = c.dispatchGet(req) - case "CertificatesClient.NewListPager": - resp, err = c.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *CertificatesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if certificatesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = certificatesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CertificatesClient.BeginCreateOrUpdate": + res.resp, res.err = c.dispatchBeginCreateOrUpdate(req) + case "CertificatesClient.BeginDelete": + res.resp, res.err = c.dispatchBeginDelete(req) + case "CertificatesClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CertificatesClient.NewListPager": + res.resp, res.err = c.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *CertificatesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -103,7 +117,7 @@ func (c *CertificatesServerTransport) dispatchBeginCreateOrUpdate(req *http.Requ const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armnginx.Certificate](req) @@ -122,13 +136,7 @@ func (c *CertificatesServerTransport) dispatchBeginCreateOrUpdate(req *http.Requ if err != nil { return nil, err } - var options *armnginx.CertificatesClientBeginCreateOrUpdateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armnginx.CertificatesClientBeginCreateOrUpdateOptions{ - Body: &body, - } - } - respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, certificateNameParam, options) + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, certificateNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -161,7 +169,7 @@ func (c *CertificatesServerTransport) dispatchBeginDelete(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -207,7 +215,7 @@ func (c *CertificatesServerTransport) dispatchGet(req *http.Request) (*http.Resp const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -246,7 +254,7 @@ func (c *CertificatesServerTransport) dispatchNewListPager(req *http.Request) (* const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -277,3 +285,9 @@ func (c *CertificatesServerTransport) dispatchNewListPager(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to CertificatesServerTransport +var certificatesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/configurations_server.go b/sdk/resourcemanager/nginx/armnginx/fake/configurations_server.go index 3b1049a4ae32..b97c1aca1272 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/configurations_server.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/configurations_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -31,7 +27,7 @@ type ConfigurationsServer struct { // BeginCreateOrUpdate is the fake for method ConfigurationsClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, options *armnginx.ConfigurationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnginx.ConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, configurationName string, body armnginx.ConfigurationRequest, options *armnginx.ConfigurationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnginx.ConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method ConfigurationsClient.BeginDelete // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent @@ -75,29 +71,48 @@ func (c *ConfigurationsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ConfigurationsClient.Analysis": - resp, err = c.dispatchAnalysis(req) - case "ConfigurationsClient.BeginCreateOrUpdate": - resp, err = c.dispatchBeginCreateOrUpdate(req) - case "ConfigurationsClient.BeginDelete": - resp, err = c.dispatchBeginDelete(req) - case "ConfigurationsClient.Get": - resp, err = c.dispatchGet(req) - case "ConfigurationsClient.NewListPager": - resp, err = c.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ConfigurationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if configurationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationsClient.Analysis": + res.resp, res.err = c.dispatchAnalysis(req) + case "ConfigurationsClient.BeginCreateOrUpdate": + res.resp, res.err = c.dispatchBeginCreateOrUpdate(req) + case "ConfigurationsClient.BeginDelete": + res.resp, res.err = c.dispatchBeginDelete(req) + case "ConfigurationsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConfigurationsClient.NewListPager": + res.resp, res.err = c.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *ConfigurationsServerTransport) dispatchAnalysis(req *http.Request) (*http.Response, error) { @@ -107,7 +122,7 @@ func (c *ConfigurationsServerTransport) dispatchAnalysis(req *http.Request) (*ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/analyze` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armnginx.AnalysisCreate](req) @@ -156,7 +171,7 @@ func (c *ConfigurationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armnginx.ConfigurationRequest](req) @@ -175,13 +190,7 @@ func (c *ConfigurationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Re if err != nil { return nil, err } - var options *armnginx.ConfigurationsClientBeginCreateOrUpdateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armnginx.ConfigurationsClientBeginCreateOrUpdateOptions{ - Body: &body, - } - } - respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, configurationNameParam, options) + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, configurationNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -214,7 +223,7 @@ func (c *ConfigurationsServerTransport) dispatchBeginDelete(req *http.Request) ( const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -260,7 +269,7 @@ func (c *ConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Re const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { + if len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -299,7 +308,7 @@ func (c *ConfigurationsServerTransport) dispatchNewListPager(req *http.Request) const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/configurations` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -330,3 +339,9 @@ func (c *ConfigurationsServerTransport) dispatchNewListPager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationsServerTransport +var configurationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/defaultwafpolicy_server.go b/sdk/resourcemanager/nginx/armnginx/fake/defaultwafpolicy_server.go new file mode 100644 index 000000000000..9657bcfbfef1 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/fake/defaultwafpolicy_server.go @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "net/http" + "net/url" + "regexp" +) + +// DefaultWafPolicyServer is a fake server for instances of the armnginx.DefaultWafPolicyClient type. +type DefaultWafPolicyServer struct { + // List is the fake for method DefaultWafPolicyClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, deploymentName string, options *armnginx.DefaultWafPolicyClientListOptions) (resp azfake.Responder[armnginx.DefaultWafPolicyClientListResponse], errResp azfake.ErrorResponder) +} + +// NewDefaultWafPolicyServerTransport creates a new instance of DefaultWafPolicyServerTransport with the provided implementation. +// The returned DefaultWafPolicyServerTransport instance is connected to an instance of armnginx.DefaultWafPolicyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDefaultWafPolicyServerTransport(srv *DefaultWafPolicyServer) *DefaultWafPolicyServerTransport { + return &DefaultWafPolicyServerTransport{srv: srv} +} + +// DefaultWafPolicyServerTransport connects instances of armnginx.DefaultWafPolicyClient to instances of DefaultWafPolicyServer. +// Don't use this type directly, use NewDefaultWafPolicyServerTransport instead. +type DefaultWafPolicyServerTransport struct { + srv *DefaultWafPolicyServer +} + +// Do implements the policy.Transporter interface for DefaultWafPolicyServerTransport. +func (d *DefaultWafPolicyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return d.dispatchToMethodFake(req, method) +} + +func (d *DefaultWafPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if defaultWafPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = defaultWafPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DefaultWafPolicyClient.List": + res.resp, res.err = d.dispatchList(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (d *DefaultWafPolicyServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if d.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDefaultWafPolicies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.List(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentDefaultWafPolicyListResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to DefaultWafPolicyServerTransport +var defaultWafPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/deployments_server.go b/sdk/resourcemanager/nginx/armnginx/fake/deployments_server.go index fcd80b00ae5e..ea94462160c2 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/deployments_server.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/deployments_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,7 +15,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" "net/http" "net/url" - "reflect" "regexp" ) @@ -27,7 +22,7 @@ import ( type DeploymentsServer struct { // BeginCreateOrUpdate is the fake for method DeploymentsClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, options *armnginx.DeploymentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnginx.DeploymentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, body armnginx.Deployment, options *armnginx.DeploymentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnginx.DeploymentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method DeploymentsClient.BeginDelete // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent @@ -46,8 +41,8 @@ type DeploymentsServer struct { NewListByResourceGroupPager func(resourceGroupName string, options *armnginx.DeploymentsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armnginx.DeploymentsClientListByResourceGroupResponse]) // BeginUpdate is the fake for method DeploymentsClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, options *armnginx.DeploymentsClientBeginUpdateOptions) (resp azfake.PollerResponder[armnginx.DeploymentsClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, body armnginx.DeploymentUpdateParameters, options *armnginx.DeploymentsClientBeginUpdateOptions) (resp azfake.PollerResponder[armnginx.DeploymentsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewDeploymentsServerTransport creates a new instance of DeploymentsServerTransport with the provided implementation. @@ -83,31 +78,50 @@ func (d *DeploymentsServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DeploymentsClient.BeginCreateOrUpdate": - resp, err = d.dispatchBeginCreateOrUpdate(req) - case "DeploymentsClient.BeginDelete": - resp, err = d.dispatchBeginDelete(req) - case "DeploymentsClient.Get": - resp, err = d.dispatchGet(req) - case "DeploymentsClient.NewListPager": - resp, err = d.dispatchNewListPager(req) - case "DeploymentsClient.NewListByResourceGroupPager": - resp, err = d.dispatchNewListByResourceGroupPager(req) - case "DeploymentsClient.BeginUpdate": - resp, err = d.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DeploymentsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if deploymentsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = deploymentsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DeploymentsClient.BeginCreateOrUpdate": + res.resp, res.err = d.dispatchBeginCreateOrUpdate(req) + case "DeploymentsClient.BeginDelete": + res.resp, res.err = d.dispatchBeginDelete(req) + case "DeploymentsClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DeploymentsClient.NewListPager": + res.resp, res.err = d.dispatchNewListPager(req) + case "DeploymentsClient.NewListByResourceGroupPager": + res.resp, res.err = d.dispatchNewListByResourceGroupPager(req) + case "DeploymentsClient.BeginUpdate": + res.resp, res.err = d.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -119,7 +133,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Reque const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armnginx.Deployment](req) @@ -134,13 +148,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Reque if err != nil { return nil, err } - var options *armnginx.DeploymentsClientBeginCreateOrUpdateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armnginx.DeploymentsClientBeginCreateOrUpdateOptions{ - Body: &body, - } - } - respr, errRespr := d.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, options) + respr, errRespr := d.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -173,7 +181,7 @@ func (d *DeploymentsServerTransport) dispatchBeginDelete(req *http.Request) (*ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -215,7 +223,7 @@ func (d *DeploymentsServerTransport) dispatchGet(req *http.Request) (*http.Respo const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -250,7 +258,7 @@ func (d *DeploymentsServerTransport) dispatchNewListPager(req *http.Request) (*h const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resp := d.srv.NewListPager(nil) @@ -283,7 +291,7 @@ func (d *DeploymentsServerTransport) dispatchNewListByResourceGroupPager(req *ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) @@ -320,7 +328,7 @@ func (d *DeploymentsServerTransport) dispatchBeginUpdate(req *http.Request) (*ht const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armnginx.DeploymentUpdateParameters](req) @@ -335,13 +343,7 @@ func (d *DeploymentsServerTransport) dispatchBeginUpdate(req *http.Request) (*ht if err != nil { return nil, err } - var options *armnginx.DeploymentsClientBeginUpdateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armnginx.DeploymentsClientBeginUpdateOptions{ - Body: &body, - } - } - respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, options) + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -354,9 +356,9 @@ func (d *DeploymentsServerTransport) dispatchBeginUpdate(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { d.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { d.beginUpdate.remove(req) @@ -364,3 +366,9 @@ func (d *DeploymentsServerTransport) dispatchBeginUpdate(req *http.Request) (*ht return resp, nil } + +// set this to conditionally intercept incoming requests to DeploymentsServerTransport +var deploymentsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/internal.go b/sdk/resourcemanager/nginx/armnginx/fake/internal.go index 5f75802a569e..7425b6a669e2 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/internal.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/internal.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -14,6 +10,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/nginx/armnginx/fake/operations_server.go b/sdk/resourcemanager/nginx/armnginx/fake/operations_server.go index 036ba95be4f4..07b1fa327c3b 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/operations_server.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/operations_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -51,21 +47,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +109,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/server_factory.go b/sdk/resourcemanager/nginx/armnginx/fake/server_factory.go index 25e353dcbcc7..0c7c358a4fe6 100644 --- a/sdk/resourcemanager/nginx/armnginx/fake/server_factory.go +++ b/sdk/resourcemanager/nginx/armnginx/fake/server_factory.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,11 +15,26 @@ import ( // ServerFactory is a fake server for instances of the armnginx.ClientFactory type. type ServerFactory struct { - APIKeysServer APIKeysServer - CertificatesServer CertificatesServer + // APIKeysServer contains the fakes for client APIKeysClient + APIKeysServer APIKeysServer + + // CertificatesServer contains the fakes for client CertificatesClient + CertificatesServer CertificatesServer + + // ConfigurationsServer contains the fakes for client ConfigurationsClient ConfigurationsServer ConfigurationsServer - DeploymentsServer DeploymentsServer - OperationsServer OperationsServer + + // DefaultWafPolicyServer contains the fakes for client DefaultWafPolicyClient + DefaultWafPolicyServer DefaultWafPolicyServer + + // DeploymentsServer contains the fakes for client DeploymentsClient + DeploymentsServer DeploymentsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // WafPolicyServer contains the fakes for client WafPolicyClient + WafPolicyServer WafPolicyServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -38,13 +49,15 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armnginx.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAPIKeysServer *APIKeysServerTransport - trCertificatesServer *CertificatesServerTransport - trConfigurationsServer *ConfigurationsServerTransport - trDeploymentsServer *DeploymentsServerTransport - trOperationsServer *OperationsServerTransport + srv *ServerFactory + trMu sync.Mutex + trAPIKeysServer *APIKeysServerTransport + trCertificatesServer *CertificatesServerTransport + trConfigurationsServer *ConfigurationsServerTransport + trDefaultWafPolicyServer *DefaultWafPolicyServerTransport + trDeploymentsServer *DeploymentsServerTransport + trOperationsServer *OperationsServerTransport + trWafPolicyServer *WafPolicyServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -71,12 +84,20 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewConfigurationsServerTransport(&s.srv.ConfigurationsServer) }) resp, err = s.trConfigurationsServer.Do(req) + case "DefaultWafPolicyClient": + initServer(s, &s.trDefaultWafPolicyServer, func() *DefaultWafPolicyServerTransport { + return NewDefaultWafPolicyServerTransport(&s.srv.DefaultWafPolicyServer) + }) + resp, err = s.trDefaultWafPolicyServer.Do(req) case "DeploymentsClient": initServer(s, &s.trDeploymentsServer, func() *DeploymentsServerTransport { return NewDeploymentsServerTransport(&s.srv.DeploymentsServer) }) resp, err = s.trDeploymentsServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "WafPolicyClient": + initServer(s, &s.trWafPolicyServer, func() *WafPolicyServerTransport { return NewWafPolicyServerTransport(&s.srv.WafPolicyServer) }) + resp, err = s.trWafPolicyServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/nginx/armnginx/fake/time_rfc3339.go b/sdk/resourcemanager/nginx/armnginx/fake/time_rfc3339.go deleted file mode 100644 index 81f308b0d343..000000000000 --- a/sdk/resourcemanager/nginx/armnginx/fake/time_rfc3339.go +++ /dev/null @@ -1,110 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) - -const ( - utcDateTime = "2006-01-02T15:04:05.999999999" - utcDateTimeJSON = `"` + utcDateTime + `"` - utcDateTimeNoT = "2006-01-02 15:04:05.999999999" - utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` - dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` - dateTimeJSON = `"` + time.RFC3339Nano + `"` - dateTimeJSONNoT = `"` + dateTimeNoT + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = dateTimeJSON - } else if tzOffset { - layout = dateTimeJSONNoT - } else if hasT { - layout = utcDateTimeJSON - } else { - layout = utcDateTimeJSONNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - tzOffset := tzOffsetRegex.Match(data) - hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") - var layout string - if tzOffset && hasT { - layout = time.RFC3339Nano - } else if tzOffset { - layout = dateTimeNoT - } else if hasT { - layout = utcDateTime - } else { - layout = utcDateTimeNoT - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func (t dateTimeRFC3339) String() string { - return time.Time(t).Format(time.RFC3339Nano) -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || string(data) == "null" { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/nginx/armnginx/fake/wafpolicy_server.go b/sdk/resourcemanager/nginx/armnginx/fake/wafpolicy_server.go new file mode 100644 index 000000000000..4b0426654af4 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/fake/wafpolicy_server.go @@ -0,0 +1,293 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "net/http" + "net/url" + "regexp" +) + +// WafPolicyServer is a fake server for instances of the armnginx.WafPolicyClient type. +type WafPolicyServer struct { + // BeginCreate is the fake for method WafPolicyClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, body armnginx.DeploymentWafPolicy, options *armnginx.WafPolicyClientBeginCreateOptions) (resp azfake.PollerResponder[armnginx.WafPolicyClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method WafPolicyClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, options *armnginx.WafPolicyClientBeginDeleteOptions) (resp azfake.PollerResponder[armnginx.WafPolicyClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WafPolicyClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, options *armnginx.WafPolicyClientGetOptions) (resp azfake.Responder[armnginx.WafPolicyClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WafPolicyClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, deploymentName string, options *armnginx.WafPolicyClientListOptions) (resp azfake.PagerResponder[armnginx.WafPolicyClientListResponse]) +} + +// NewWafPolicyServerTransport creates a new instance of WafPolicyServerTransport with the provided implementation. +// The returned WafPolicyServerTransport instance is connected to an instance of armnginx.WafPolicyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWafPolicyServerTransport(srv *WafPolicyServer) *WafPolicyServerTransport { + return &WafPolicyServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armnginx.WafPolicyClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armnginx.WafPolicyClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armnginx.WafPolicyClientListResponse]](), + } +} + +// WafPolicyServerTransport connects instances of armnginx.WafPolicyClient to instances of WafPolicyServer. +// Don't use this type directly, use NewWafPolicyServerTransport instead. +type WafPolicyServerTransport struct { + srv *WafPolicyServer + beginCreate *tracker[azfake.PollerResponder[armnginx.WafPolicyClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armnginx.WafPolicyClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armnginx.WafPolicyClientListResponse]] +} + +// Do implements the policy.Transporter interface for WafPolicyServerTransport. +func (w *WafPolicyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WafPolicyServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if wafPolicyServerTransportInterceptor != nil { + res.resp, res.err, intercepted = wafPolicyServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WafPolicyClient.BeginCreate": + res.resp, res.err = w.dispatchBeginCreate(req) + case "WafPolicyClient.BeginDelete": + res.resp, res.err = w.dispatchBeginDelete(req) + case "WafPolicyClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WafPolicyClient.NewListPager": + res.resp, res.err = w.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WafPolicyServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := w.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/wafPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnginx.DeploymentWafPolicy](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + wafPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("wafPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginCreate(req.Context(), resourceGroupNameParam, deploymentNameParam, wafPolicyNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + w.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + w.beginCreate.remove(req) + } + + return resp, nil +} + +func (w *WafPolicyServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if w.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := w.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/wafPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + wafPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("wafPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginDelete(req.Context(), resourceGroupNameParam, deploymentNameParam, wafPolicyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + w.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + w.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + w.beginDelete.remove(req) + } + + return resp, nil +} + +func (w *WafPolicyServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/wafPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + wafPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("wafPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, deploymentNameParam, wafPolicyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentWafPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WafPolicyServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Nginx\.NginxPlus/nginxDeployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/wafPolicies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListPager(resourceGroupNameParam, deploymentNameParam, nil) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armnginx.WafPolicyClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WafPolicyServerTransport +var wafPolicyServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/nginx/armnginx/go.mod b/sdk/resourcemanager/nginx/armnginx/go.mod index fd8e6de9b039..5e0e84cacf1f 100644 --- a/sdk/resourcemanager/nginx/armnginx/go.mod +++ b/sdk/resourcemanager/nginx/armnginx/go.mod @@ -1,21 +1,23 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3 -go 1.23.0 +go 1.24.0 + +toolchain go1.24.7 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.5.0 // indirect + github.com/golang-jwt/jwt/v5 v5.3.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.40.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect + golang.org/x/crypto v0.43.0 // indirect + golang.org/x/net v0.46.0 // indirect + golang.org/x/sys v0.37.0 // indirect + golang.org/x/text v0.30.0 // indirect ) diff --git a/sdk/resourcemanager/nginx/armnginx/go.sum b/sdk/resourcemanager/nginx/armnginx/go.sum index 49e874cd7954..c13e7f6cffad 100644 --- a/sdk/resourcemanager/nginx/armnginx/go.sum +++ b/sdk/resourcemanager/nginx/armnginx/go.sum @@ -1,23 +1,19 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 h1:Wc1ml6QlJs2BHQ/9Bqu1jiyggbsSjramq2oUmp5WeIo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1 h1:5YTBM8QDVIBN3sxBil89WfdAAqDZbyJTgh688DSxX5w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0 h1:KpMC6LFL7mqpExyMC9jVOYRiVhLmamjeZfRsUpB7l4s= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0/go.mod h1:J7MUC/wtRpfGVbQ5sIItY5/FuVWmvzlY21WAOfQnq/I= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/AzureAD/microsoft-authentication-library-for-go v1.5.0 h1:XkkQbfMyuH2jTSjQjSoihryI8GINRcs4xp8lNawg0FI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.5.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU= @@ -28,18 +24,16 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmd github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI= -github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= -golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= +golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= +golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= +golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/nginx/armnginx/models.go b/sdk/resourcemanager/nginx/armnginx/models.go index 056a6ade3d80..5e854a07ef09 100644 --- a/sdk/resourcemanager/nginx/armnginx/models.go +++ b/sdk/resourcemanager/nginx/armnginx/models.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -17,7 +13,9 @@ type AnalysisCreate struct { } type AnalysisCreateConfig struct { - Files []*ConfigurationFile + Files []*ConfigurationFile + + // Nginx Configuration Package Package *ConfigurationPackage ProtectedFiles []*ConfigurationProtectedFileRequest @@ -67,34 +65,45 @@ type AutoUpgradeProfile struct { UpgradeChannel *string } +// Certificate - Nginx Certificate type Certificate struct { - Location *string + // The geo-location where the resource lives + Location *string + + // Nginx Certificate Properties Properties *CertificateProperties - // READ-ONLY + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } +// CertificateErrorResponseBody - Nginx Certificate Error Response Body type CertificateErrorResponseBody struct { Code *string Message *string } +// CertificateListResponse - Nginx Certificate List Response type CertificateListResponse struct { + // REQUIRED; The NginxCertificate items on this page + Value []*Certificate + + // The link to the next page of items NextLink *string - Value []*Certificate } +// CertificateProperties - Nginx Certificate Properties type CertificateProperties struct { + // Nginx Certificate Error Response Body CertificateError *CertificateErrorResponseBody CertificateVirtualPath *string KeyVaultSecretID *string @@ -106,13 +115,14 @@ type CertificateProperties struct { // READ-ONLY KeyVaultSecretVersion *string - // READ-ONLY + // READ-ONLY; Provisioning State ProvisioningState *ProvisioningState // READ-ONLY SHA1Thumbprint *string } +// ConfigurationFile - Nginx Configuration File type ConfigurationFile struct { Content *string VirtualPath *string @@ -120,18 +130,20 @@ type ConfigurationFile struct { // ConfigurationListResponse - Response of a list operation. type ConfigurationListResponse struct { - // Link to the next set of results, if any. - NextLink *string - - // Results of a list operation. + // REQUIRED; The NginxConfigurationResponse items on this page Value []*ConfigurationResponse + + // The link to the next page of items + NextLink *string } +// ConfigurationPackage - Nginx Configuration Package type ConfigurationPackage struct { Data *string ProtectedFiles []*string } +// ConfigurationProtectedFileRequest - Nginx Configuration Protected File Request type ConfigurationProtectedFileRequest struct { // The content of the protected file. This value is a PUT only value. If you perform a GET request on this value, it will // be empty because it is a protected file. @@ -144,6 +156,7 @@ type ConfigurationProtectedFileRequest struct { VirtualPath *string } +// ConfigurationProtectedFileResponse - Nginx Configuration Protected File Response type ConfigurationProtectedFileResponse struct { // The hash of the content of the file. This value is used to determine if the file has changed. ContentHash *string @@ -152,7 +165,9 @@ type ConfigurationProtectedFileResponse struct { VirtualPath *string } +// ConfigurationRequest - Nginx Configuration Request type ConfigurationRequest struct { + // Nginx Configuration Request Properties Properties *ConfigurationRequestProperties // READ-ONLY @@ -168,70 +183,92 @@ type ConfigurationRequest struct { Type *string } +// ConfigurationRequestProperties - Nginx Configuration Request Properties type ConfigurationRequestProperties struct { - Files []*ConfigurationFile + Files []*ConfigurationFile + + // Nginx Configuration Package Package *ConfigurationPackage ProtectedFiles []*ConfigurationProtectedFileRequest RootFile *string - // READ-ONLY + // READ-ONLY; Provisioning State ProvisioningState *ProvisioningState } +// ConfigurationResponse - Nginx Configuration Response type ConfigurationResponse struct { + // Nginx Configuration Response Properties Properties *ConfigurationResponseProperties - // READ-ONLY + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } +// ConfigurationResponseProperties - Nginx Configuration Response Properties type ConfigurationResponseProperties struct { - Files []*ConfigurationFile + Files []*ConfigurationFile + + // Nginx Configuration Package Package *ConfigurationPackage ProtectedFiles []*ConfigurationProtectedFileResponse RootFile *string - // READ-ONLY + // READ-ONLY; Provisioning State ProvisioningState *ProvisioningState } +// Deployment - Nginx Deployment type Deployment struct { - Identity *IdentityProperties - Location *string + // REQUIRED; The geo-location where the resource lives + Location *string + + // Identity Properties + Identity *IdentityProperties + + // Nginx Deployment Properties Properties *DeploymentProperties - SKU *ResourceSKU - // Dictionary of + // Resource Sku + SKU *ResourceSKU + + // Resource tags. Tags map[string]*string - // READ-ONLY + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } +// DeploymentAPIKeyListResponse - Nginx Deployment Api Key List Response type DeploymentAPIKeyListResponse struct { + // REQUIRED; The NginxDeploymentApiKeyResponse items on this page + Value []*DeploymentAPIKeyResponse + + // The link to the next page of items NextLink *string - Value []*DeploymentAPIKeyResponse } +// DeploymentAPIKeyRequest - Nginx Deployment Api Key Request type DeploymentAPIKeyRequest struct { + // Nginx Deployment Api Key Request Properties Properties *DeploymentAPIKeyRequestProperties // READ-ONLY @@ -240,10 +277,14 @@ type DeploymentAPIKeyRequest struct { // READ-ONLY Name *string + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + // READ-ONLY Type *string } +// DeploymentAPIKeyRequestProperties - Nginx Deployment Api Key Request Properties type DeploymentAPIKeyRequestProperties struct { // The time after which this Dataplane API Key is no longer valid. EndDateTime *time.Time @@ -253,19 +294,25 @@ type DeploymentAPIKeyRequestProperties struct { SecretText *string } +// DeploymentAPIKeyResponse - Nginx Deployment Api Key Response type DeploymentAPIKeyResponse struct { + // Nginx Deployment Api Key Response Properties Properties *DeploymentAPIKeyResponseProperties - // READ-ONLY + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY + // READ-ONLY; The name of the resource Name *string - // READ-ONLY + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } +// DeploymentAPIKeyResponseProperties - Nginx Deployment Api Key Response Properties type DeploymentAPIKeyResponseProperties struct { // The time after which this Dataplane API Key is no longer valid. EndDateTime *time.Time @@ -274,24 +321,50 @@ type DeploymentAPIKeyResponseProperties struct { Hint *string } +// DeploymentDefaultWafPolicyListResponse - Nginx Deployment Default Waf Policy List Response +type DeploymentDefaultWafPolicyListResponse struct { + NextLink *string + Value []*DeploymentDefaultWafPolicyProperties +} + +// DeploymentDefaultWafPolicyProperties - Nginx Deployment Default Waf Policy Properties +type DeploymentDefaultWafPolicyProperties struct { + // READ-ONLY + Content []byte + + // READ-ONLY + Filepath *string +} + +// DeploymentListResponse - Nginx Deployment List Response type DeploymentListResponse struct { + // REQUIRED; The NginxDeployment items on this page + Value []*Deployment + + // The link to the next page of items NextLink *string - Value []*Deployment } +// DeploymentProperties - Nginx Deployment Properties type DeploymentProperties struct { // Autoupgrade settings of a deployment. AutoUpgradeProfile *AutoUpgradeProfile EnableDiagnosticsSupport *bool - Logging *Logging - NetworkProfile *NetworkProfile + + // Nginx Logging + Logging *Logging + + // Nginx Network Profile + NetworkProfile *NetworkProfile // Settings for NGINX App Protect (NAP) NginxAppProtect *DeploymentPropertiesNginxAppProtect // Information on how the deployment will be scaled. ScalingProperties *DeploymentScalingProperties - UserProfile *DeploymentUserProfile + + // Nginx Deployment User Profile + UserProfile *DeploymentUserProfile // READ-ONLY; Dataplane API endpoint for the caller to update the NGINX state of the deployment. DataplaneAPIEndpoint *string @@ -302,7 +375,7 @@ type DeploymentProperties struct { // READ-ONLY NginxVersion *string - // READ-ONLY + // READ-ONLY; Provisioning State ProvisioningState *ProvisioningState } @@ -329,29 +402,44 @@ type DeploymentScalingPropertiesAutoScaleSettings struct { Profiles []*ScaleProfile } +// DeploymentUpdateParameters - Nginx Deployment Update Parameters type DeploymentUpdateParameters struct { - Identity *IdentityProperties - Location *string + // Identity Properties + Identity *IdentityProperties + + // The geo-location where the resource lives + Location *string + + // Nginx Deployment Update Properties Properties *DeploymentUpdateProperties - SKU *ResourceSKU - // Dictionary of + // Resource Sku + SKU *ResourceSKU + + // Dictionary of Tags map[string]*string } +// DeploymentUpdateProperties - Nginx Deployment Update Properties type DeploymentUpdateProperties struct { // Autoupgrade settings of a deployment. AutoUpgradeProfile *AutoUpgradeProfile EnableDiagnosticsSupport *bool - Logging *Logging - NetworkProfile *NetworkProfile + + // Nginx Logging + Logging *Logging + + // Nginx Network Profile + NetworkProfile *NetworkProfile // Update settings for NGINX App Protect (NAP) NginxAppProtect *DeploymentUpdatePropertiesNginxAppProtect // Information on how the deployment will be scaled. ScalingProperties *DeploymentScalingProperties - UserProfile *DeploymentUserProfile + + // Nginx Deployment User Profile + UserProfile *DeploymentUserProfile } // DeploymentUpdatePropertiesNginxAppProtect - Update settings for NGINX App Protect (NAP) @@ -360,12 +448,116 @@ type DeploymentUpdatePropertiesNginxAppProtect struct { WebApplicationFirewallSettings *WebApplicationFirewallSettings } +// DeploymentUserProfile - Nginx Deployment User Profile type DeploymentUserProfile struct { // The preferred support contact email address of the user used for sending alerts and notification. Can be an empty string // or a valid email address. PreferredEmail *string } +// DeploymentWafPolicy - Nginx Deployment Waf Policy +type DeploymentWafPolicy struct { + // Nginx Deployment Waf Policy Properties + Properties *DeploymentWafPolicyProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DeploymentWafPolicyApplyingStatus - Nginx Deployment Waf Policy Applying Status +type DeploymentWafPolicyApplyingStatus struct { + // READ-ONLY; Machine readable code indicating the applying status code of a WAF Policy. + Code *NginxDeploymentWafPolicyApplyingStatusCode + + // READ-ONLY; A readable string of the current status, and sometimes have the reason for the current state. + DisplayStatus *string + + // READ-ONLY; The date and time in UTC the current applying status was set. + Time *string +} + +// DeploymentWafPolicyCompilingStatus - Nginx Deployment Waf Policy Compiling Status +type DeploymentWafPolicyCompilingStatus struct { + // READ-ONLY; Machine readable code indicating the compilation status of a WAF Policy. + Code *NginxDeploymentWafPolicyCompilingStatusCode + + // READ-ONLY; A readable string of the current status, and sometimes have the reason for the current state. If the CompilingStatus + // is Failed the Display Status will be The waf Policy failed to compile. + DisplayStatus *string + + // READ-ONLY; The date and time the policy was compiled in UTC. + Time *string +} + +// DeploymentWafPolicyListResponse - Nginx Deployment Waf Policy List Response +type DeploymentWafPolicyListResponse struct { + // REQUIRED; The NginxDeploymentWafPolicyMetadata items on this page + Value []*DeploymentWafPolicyMetadata + + // The link to the next page of items + NextLink *string +} + +// DeploymentWafPolicyMetadata - Nginx Deployment Waf Policy Metadata +type DeploymentWafPolicyMetadata struct { + // Nginx Deployment Waf Policy Metadata Properties + Properties *DeploymentWafPolicyMetadataProperties + + // READ-ONLY + ID *string + + // READ-ONLY + Name *string + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY + Type *string +} + +// DeploymentWafPolicyMetadataProperties - Nginx Deployment Waf Policy Metadata Properties +type DeploymentWafPolicyMetadataProperties struct { + // READ-ONLY; Nginx Deployment Waf Policy Applying Status + ApplyingState *DeploymentWafPolicyApplyingStatus + + // READ-ONLY; Nginx Deployment Waf Policy Compiling Status + CompilingState *DeploymentWafPolicyCompilingStatus + + // READ-ONLY + Filepath *string + + // READ-ONLY; Provisioning State + ProvisioningState *ProvisioningState +} + +// DeploymentWafPolicyProperties - Nginx Deployment Waf Policy Properties +type DeploymentWafPolicyProperties struct { + // The byte content of the Policy + Content []byte + + // The file path where the Policy is to be saved + Filepath *string + + // READ-ONLY; Nginx Deployment Waf Policy Applying Status + ApplyingState *DeploymentWafPolicyApplyingStatus + + // READ-ONLY; Nginx Deployment Waf Policy Compiling Status + CompilingState *DeploymentWafPolicyCompilingStatus + + // READ-ONLY; Provisioning State + ProvisioningState *ProvisioningState +} + // DiagnosticItem - A diagnostic is a message associated with an NGINX config. The Analyzer returns diagnostics with a level // indicating the importance of the diagnostic with optional category. type DiagnosticItem struct { @@ -397,15 +589,18 @@ type DiagnosticItem struct { ID *string } +// FrontendIPConfiguration - Nginx Frontend IP Configuration type FrontendIPConfiguration struct { PrivateIPAddresses []*PrivateIPAddress PublicIPAddresses []*PublicIPAddress } +// IdentityProperties - Identity Properties type IdentityProperties struct { + // Identity Type Type *IdentityType - // Dictionary of + // Dictionary of UserAssignedIdentities map[string]*UserIdentityProperties // READ-ONLY @@ -415,65 +610,92 @@ type IdentityProperties struct { TenantID *string } +// Logging - Nginx Logging type Logging struct { + // Nginx Storage Account StorageAccount *StorageAccount } +// NetworkInterfaceConfiguration - Nginx Network Interface Configuration type NetworkInterfaceConfiguration struct { SubnetID *string } +// NetworkProfile - Nginx Network Profile type NetworkProfile struct { - FrontEndIPConfiguration *FrontendIPConfiguration + // Nginx Frontend IP Configuration + FrontEndIPConfiguration *FrontendIPConfiguration + + // Nginx Network Interface Configuration NetworkInterfaceConfiguration *NetworkInterfaceConfiguration } -// OperationDisplay - The object that represents the operation. +// Operation - REST API Operation +// +// Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + // Resource Manager/control-plane operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for and operation. type OperationDisplay struct { - // Description of the operation, e.g., 'Write deployments'. + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // Operation type, e.g., read, write, delete, etc. + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". Operation *string - // Service provider: Nginx.NginxPlus + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". Provider *string - // Type on which the operation is performed, e.g., 'deployments'. + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". Resource *string } -// OperationListResult - Result of GET request to list Nginx.NginxPlus operations. +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. type OperationListResult struct { - // URL to get the next set of operation list results if there are any. - NextLink *string - - // List of operations supported by the Nginx.NginxPlus provider. - Value []*OperationResult -} + // REQUIRED; The Operation items on this page + Value []*Operation -// OperationResult - A Nginx.NginxPlus REST API operation. -type OperationResult struct { - // The object that represents the operation. - Display *OperationDisplay - - // Indicates whether the operation is a data action - IsDataAction *bool - - // Operation name: {provider}/{resource}/{operation} - Name *string + // The link to the next page of items + NextLink *string } +// PrivateIPAddress - Nginx Private IP Address type PrivateIPAddress struct { - PrivateIPAddress *string + PrivateIPAddress *string + + // Nginx Private IP Allocation Method PrivateIPAllocationMethod *NginxPrivateIPAllocationMethod SubnetID *string } +// PublicIPAddress - Nginx Public IP Address type PublicIPAddress struct { ID *string } +// ResourceSKU - Resource Sku type ResourceSKU struct { // REQUIRED; Name of the SKU. Name *string @@ -497,6 +719,7 @@ type ScaleProfileCapacity struct { Min *int32 } +// StorageAccount - Nginx Storage Account type StorageAccount struct { AccountName *string ContainerName *string @@ -523,6 +746,7 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// UserIdentityProperties - User Identity Properties type UserIdentityProperties struct { // READ-ONLY ClientID *string @@ -558,6 +782,9 @@ type WebApplicationFirewallSettings struct { // WebApplicationFirewallStatus - The status of the NGINX App Protect Web Application Firewall type WebApplicationFirewallStatus struct { + // NGINX App Protect WAF release version + WafRelease *string + // READ-ONLY; Package containing attack signatures for the NGINX App Protect Web Application Firewall (WAF). AttackSignaturesPackage *WebApplicationFirewallPackage diff --git a/sdk/resourcemanager/nginx/armnginx/models_serde.go b/sdk/resourcemanager/nginx/armnginx/models_serde.go index fcc20547e394..e8c6bad309c1 100644 --- a/sdk/resourcemanager/nginx/armnginx/models_serde.go +++ b/sdk/resourcemanager/nginx/armnginx/models_serde.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -12,6 +8,7 @@ import ( "encoding/json" "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "reflect" ) @@ -812,6 +809,7 @@ func (d DeploymentAPIKeyRequest) MarshalJSON() ([]byte, error) { populate(objectMap, "id", d.ID) populate(objectMap, "name", d.Name) populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -834,6 +832,9 @@ func (d *DeploymentAPIKeyRequest) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &d.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) @@ -882,6 +883,7 @@ func (d DeploymentAPIKeyResponse) MarshalJSON() ([]byte, error) { populate(objectMap, "id", d.ID) populate(objectMap, "name", d.Name) populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -904,6 +906,9 @@ func (d *DeploymentAPIKeyResponse) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &d.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) @@ -946,6 +951,72 @@ func (d *DeploymentAPIKeyResponseProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DeploymentDefaultWafPolicyListResponse. +func (d DeploymentDefaultWafPolicyListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentDefaultWafPolicyListResponse. +func (d *DeploymentDefaultWafPolicyListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentDefaultWafPolicyProperties. +func (d DeploymentDefaultWafPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateByteArray(objectMap, "content", d.Content, func() any { + return runtime.EncodeByteArray(d.Content, runtime.Base64StdFormat) + }) + populate(objectMap, "filepath", d.Filepath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentDefaultWafPolicyProperties. +func (d *DeploymentDefaultWafPolicyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &d.Content, runtime.Base64StdFormat) + } + delete(rawMsg, key) + case "filepath": + err = unpopulate(val, "Filepath", &d.Filepath) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DeploymentListResponse. func (d DeploymentListResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1281,6 +1352,279 @@ func (d *DeploymentUserProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicy. +func (d DeploymentWafPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicy. +func (d *DeploymentWafPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicyApplyingStatus. +func (d DeploymentWafPolicyApplyingStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", d.Code) + populate(objectMap, "displayStatus", d.DisplayStatus) + populate(objectMap, "time", d.Time) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicyApplyingStatus. +func (d *DeploymentWafPolicyApplyingStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &d.Code) + delete(rawMsg, key) + case "displayStatus": + err = unpopulate(val, "DisplayStatus", &d.DisplayStatus) + delete(rawMsg, key) + case "time": + err = unpopulate(val, "Time", &d.Time) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicyCompilingStatus. +func (d DeploymentWafPolicyCompilingStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", d.Code) + populate(objectMap, "displayStatus", d.DisplayStatus) + populate(objectMap, "time", d.Time) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicyCompilingStatus. +func (d *DeploymentWafPolicyCompilingStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &d.Code) + delete(rawMsg, key) + case "displayStatus": + err = unpopulate(val, "DisplayStatus", &d.DisplayStatus) + delete(rawMsg, key) + case "time": + err = unpopulate(val, "Time", &d.Time) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicyListResponse. +func (d DeploymentWafPolicyListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicyListResponse. +func (d *DeploymentWafPolicyListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicyMetadata. +func (d DeploymentWafPolicyMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicyMetadata. +func (d *DeploymentWafPolicyMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicyMetadataProperties. +func (d DeploymentWafPolicyMetadataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyingState", d.ApplyingState) + populate(objectMap, "compilingState", d.CompilingState) + populate(objectMap, "filepath", d.Filepath) + populate(objectMap, "provisioningState", d.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicyMetadataProperties. +func (d *DeploymentWafPolicyMetadataProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyingState": + err = unpopulate(val, "ApplyingState", &d.ApplyingState) + delete(rawMsg, key) + case "compilingState": + err = unpopulate(val, "CompilingState", &d.CompilingState) + delete(rawMsg, key) + case "filepath": + err = unpopulate(val, "Filepath", &d.Filepath) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentWafPolicyProperties. +func (d DeploymentWafPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyingState", d.ApplyingState) + populate(objectMap, "compilingState", d.CompilingState) + populateByteArray(objectMap, "content", d.Content, func() any { + return runtime.EncodeByteArray(d.Content, runtime.Base64StdFormat) + }) + populate(objectMap, "filepath", d.Filepath) + populate(objectMap, "provisioningState", d.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWafPolicyProperties. +func (d *DeploymentWafPolicyProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyingState": + err = unpopulate(val, "ApplyingState", &d.ApplyingState) + delete(rawMsg, key) + case "compilingState": + err = unpopulate(val, "CompilingState", &d.CompilingState) + delete(rawMsg, key) + case "content": + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &d.Content, runtime.Base64StdFormat) + } + delete(rawMsg, key) + case "filepath": + err = unpopulate(val, "Filepath", &d.Filepath) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DiagnosticItem. func (d DiagnosticItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1495,6 +1839,49 @@ func (n *NetworkProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1565,41 +1952,6 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationResult. -func (o OperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "display", o.Display) - populate(objectMap, "isDataAction", o.IsDataAction) - populate(objectMap, "name", o.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResult. -func (o *OperationResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type PrivateIPAddress. func (p PrivateIPAddress) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1956,6 +2308,7 @@ func (w WebApplicationFirewallStatus) MarshalJSON() ([]byte, error) { populate(objectMap, "botSignaturesPackage", w.BotSignaturesPackage) populate(objectMap, "componentVersions", w.ComponentVersions) populate(objectMap, "threatCampaignsPackage", w.ThreatCampaignsPackage) + populate(objectMap, "wafRelease", w.WafRelease) return json.Marshal(objectMap) } @@ -1980,6 +2333,9 @@ func (w *WebApplicationFirewallStatus) UnmarshalJSON(data []byte) error { case "threatCampaignsPackage": err = unpopulate(val, "ThreatCampaignsPackage", &w.ThreatCampaignsPackage) delete(rawMsg, key) + case "wafRelease": + err = unpopulate(val, "WafRelease", &w.WafRelease) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", w, err) @@ -1998,6 +2354,16 @@ func populate(m map[string]any, k string, v any) { } } +func populateByteArray[T any](m map[string]any, k string, b []T, convert func() any) { + if azcore.IsNullValue(b) { + m[k] = nil + } else if len(b) == 0 { + return + } else { + m[k] = convert() + } +} + func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil || string(data) == "null" { return nil diff --git a/sdk/resourcemanager/nginx/armnginx/operations_client.go b/sdk/resourcemanager/nginx/armnginx/operations_client.go index 12421fb6b296..a0fa3573ebf3 100644 --- a/sdk/resourcemanager/nginx/armnginx/operations_client.go +++ b/sdk/resourcemanager/nginx/armnginx/operations_client.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -37,9 +33,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - List all operations provided by Nginx.NginxPlus for the 2024-11-01-preview api version. +// NewListPager - List the operations for the provider // -// Generated from API version 2024-11-01-preview +// Generated from API version 2025-03-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -65,14 +61,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Nginx.NginxPlus/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01-preview") + reqQP.Set("api-version", "2025-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go index a22fce17c805..0305de813e20 100644 --- a/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go +++ b/sdk/resourcemanager/nginx/armnginx/operations_client_example_test.go @@ -1,30 +1,24 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8d26b0e4c1886458fa56c22aac09c3e3e9a5c9e/specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-11-01-preview/examples/Operations_List.json +// Generated from example definition: 2025-03-01-preview/Operations_List.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armnginx.NewClientFactory("", cred, nil) + clientFactory, err := armnginx.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -39,17 +33,20 @@ func ExampleOperationsClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armnginx.OperationListResult{ - // Value: []*armnginx.OperationResult{ - // { - // Name: to.Ptr("Nginx.NginxPlus/nginxDeployments/write"), - // Display: &armnginx.OperationDisplay{ - // Description: to.Ptr("Write deployments resource"), - // Operation: to.Ptr("write"), - // Provider: to.Ptr("Nginx.NginxPlus"), - // Resource: to.Ptr("deployments"), + // page = armnginx.OperationsClientListResponse{ + // OperationListResult: armnginx.OperationListResult{ + // Value: []*armnginx.Operation{ + // { + // Name: to.Ptr("Nginx.NginxPlus/nginxDeployments/write"), + // Display: &armnginx.OperationDisplay{ + // Description: to.Ptr("Write deployments resource"), + // Operation: to.Ptr("write"), + // Provider: to.Ptr("Nginx.NginxPlus"), + // Resource: to.Ptr("deployments"), + // }, // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/nginx/armnginx/options.go b/sdk/resourcemanager/nginx/armnginx/options.go index 1050cf1dd817..c22eee42d402 100644 --- a/sdk/resourcemanager/nginx/armnginx/options.go +++ b/sdk/resourcemanager/nginx/armnginx/options.go @@ -1,17 +1,12 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx // APIKeysClientCreateOrUpdateOptions contains the optional parameters for the APIKeysClient.CreateOrUpdate method. type APIKeysClientCreateOrUpdateOptions struct { - // The API Key object containing fields (e.g. secret text, expiration date) to upsert the key. - Body *DeploymentAPIKeyRequest + // placeholder for future optional parameters } // APIKeysClientDeleteOptions contains the optional parameters for the APIKeysClient.Delete method. @@ -32,16 +27,13 @@ type APIKeysClientListOptions struct { // CertificatesClientBeginCreateOrUpdateOptions contains the optional parameters for the CertificatesClient.BeginCreateOrUpdate // method. type CertificatesClientBeginCreateOrUpdateOptions struct { - // The certificate - Body *Certificate - - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // CertificatesClientBeginDeleteOptions contains the optional parameters for the CertificatesClient.BeginDelete method. type CertificatesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -64,16 +56,13 @@ type ConfigurationsClientAnalysisOptions struct { // ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate // method. type ConfigurationsClientBeginCreateOrUpdateOptions struct { - // The NGINX configuration - Body *ConfigurationRequest - - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ConfigurationsClientBeginDeleteOptions contains the optional parameters for the ConfigurationsClient.BeginDelete method. type ConfigurationsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -87,26 +76,27 @@ type ConfigurationsClientListOptions struct { // placeholder for future optional parameters } +// DefaultWafPolicyClientListOptions contains the optional parameters for the DefaultWafPolicyClient.List method. +type DefaultWafPolicyClientListOptions struct { + // placeholder for future optional parameters +} + // DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate // method. type DeploymentsClientBeginCreateOrUpdateOptions struct { - Body *Deployment - - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. type DeploymentsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // DeploymentsClientBeginUpdateOptions contains the optional parameters for the DeploymentsClient.BeginUpdate method. type DeploymentsClientBeginUpdateOptions struct { - Body *DeploymentUpdateParameters - - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -130,3 +120,25 @@ type DeploymentsClientListOptions struct { type OperationsClientListOptions struct { // placeholder for future optional parameters } + +// WafPolicyClientBeginCreateOptions contains the optional parameters for the WafPolicyClient.BeginCreate method. +type WafPolicyClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WafPolicyClientBeginDeleteOptions contains the optional parameters for the WafPolicyClient.BeginDelete method. +type WafPolicyClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WafPolicyClientGetOptions contains the optional parameters for the WafPolicyClient.Get method. +type WafPolicyClientGetOptions struct { + // placeholder for future optional parameters +} + +// WafPolicyClientListOptions contains the optional parameters for the WafPolicyClient.NewListPager method. +type WafPolicyClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/nginx/armnginx/responses.go b/sdk/resourcemanager/nginx/armnginx/responses.go index 2b411cd67eb2..03e2faee2d15 100644 --- a/sdk/resourcemanager/nginx/armnginx/responses.go +++ b/sdk/resourcemanager/nginx/armnginx/responses.go @@ -1,15 +1,12 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx // APIKeysClientCreateOrUpdateResponse contains the response from method APIKeysClient.CreateOrUpdate. type APIKeysClientCreateOrUpdateResponse struct { + // Nginx Deployment Api Key Response DeploymentAPIKeyResponse } @@ -20,16 +17,19 @@ type APIKeysClientDeleteResponse struct { // APIKeysClientGetResponse contains the response from method APIKeysClient.Get. type APIKeysClientGetResponse struct { + // Nginx Deployment Api Key Response DeploymentAPIKeyResponse } // APIKeysClientListResponse contains the response from method APIKeysClient.NewListPager. type APIKeysClientListResponse struct { + // Nginx Deployment Api Key List Response DeploymentAPIKeyListResponse } // CertificatesClientCreateOrUpdateResponse contains the response from method CertificatesClient.BeginCreateOrUpdate. type CertificatesClientCreateOrUpdateResponse struct { + // Nginx Certificate Certificate } @@ -40,11 +40,13 @@ type CertificatesClientDeleteResponse struct { // CertificatesClientGetResponse contains the response from method CertificatesClient.Get. type CertificatesClientGetResponse struct { + // Nginx Certificate Certificate } // CertificatesClientListResponse contains the response from method CertificatesClient.NewListPager. type CertificatesClientListResponse struct { + // Nginx Certificate List Response CertificateListResponse } @@ -56,6 +58,7 @@ type ConfigurationsClientAnalysisResponse struct { // ConfigurationsClientCreateOrUpdateResponse contains the response from method ConfigurationsClient.BeginCreateOrUpdate. type ConfigurationsClientCreateOrUpdateResponse struct { + // Nginx Configuration Response ConfigurationResponse } @@ -66,6 +69,7 @@ type ConfigurationsClientDeleteResponse struct { // ConfigurationsClientGetResponse contains the response from method ConfigurationsClient.Get. type ConfigurationsClientGetResponse struct { + // Nginx Configuration Response ConfigurationResponse } @@ -75,8 +79,15 @@ type ConfigurationsClientListResponse struct { ConfigurationListResponse } +// DefaultWafPolicyClientListResponse contains the response from method DefaultWafPolicyClient.List. +type DefaultWafPolicyClientListResponse struct { + // Nginx Deployment Default Waf Policy List Response + DeploymentDefaultWafPolicyListResponse +} + // DeploymentsClientCreateOrUpdateResponse contains the response from method DeploymentsClient.BeginCreateOrUpdate. type DeploymentsClientCreateOrUpdateResponse struct { + // Nginx Deployment Deployment } @@ -87,26 +98,53 @@ type DeploymentsClientDeleteResponse struct { // DeploymentsClientGetResponse contains the response from method DeploymentsClient.Get. type DeploymentsClientGetResponse struct { + // Nginx Deployment Deployment } // DeploymentsClientListByResourceGroupResponse contains the response from method DeploymentsClient.NewListByResourceGroupPager. type DeploymentsClientListByResourceGroupResponse struct { + // Nginx Deployment List Response DeploymentListResponse } // DeploymentsClientListResponse contains the response from method DeploymentsClient.NewListPager. type DeploymentsClientListResponse struct { + // Nginx Deployment List Response DeploymentListResponse } // DeploymentsClientUpdateResponse contains the response from method DeploymentsClient.BeginUpdate. type DeploymentsClientUpdateResponse struct { + // Nginx Deployment Deployment } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // Result of GET request to list Nginx.NginxPlus operations. + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. OperationListResult } + +// WafPolicyClientCreateResponse contains the response from method WafPolicyClient.BeginCreate. +type WafPolicyClientCreateResponse struct { + // Nginx Deployment Waf Policy + DeploymentWafPolicy +} + +// WafPolicyClientDeleteResponse contains the response from method WafPolicyClient.BeginDelete. +type WafPolicyClientDeleteResponse struct { + // placeholder for future response values +} + +// WafPolicyClientGetResponse contains the response from method WafPolicyClient.Get. +type WafPolicyClientGetResponse struct { + // Nginx Deployment Waf Policy + DeploymentWafPolicy +} + +// WafPolicyClientListResponse contains the response from method WafPolicyClient.NewListPager. +type WafPolicyClientListResponse struct { + // Nginx Deployment Waf Policy List Response + DeploymentWafPolicyListResponse +} diff --git a/sdk/resourcemanager/nginx/armnginx/testdata/_metadata.json b/sdk/resourcemanager/nginx/armnginx/testdata/_metadata.json new file mode 100644 index 000000000000..3437efcfca5d --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2025-03-01-preview", + "emitterVersion": "0.8.2" +} \ No newline at end of file diff --git a/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go b/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go index a1bd429f7483..9346c7dc9730 100644 --- a/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go +++ b/sdk/resourcemanager/nginx/armnginx/time_rfc3339.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armnginx @@ -60,6 +56,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string diff --git a/sdk/resourcemanager/nginx/armnginx/tsp-location.yaml b/sdk/resourcemanager/nginx/armnginx/tsp-location.yaml new file mode 100644 index 000000000000..874f27338079 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/nginx/Nginx.Management +commit: aae85aa3e7e4fda95ea2d3abac0ba1d8159db214 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/nginx/armnginx/version.go b/sdk/resourcemanager/nginx/armnginx/version.go new file mode 100644 index 000000000000..93fd8d429dbd --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/version.go @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. + +package armnginx + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx" + moduleVersion = "v3.1.0-beta.3" +) diff --git a/sdk/resourcemanager/nginx/armnginx/wafpolicy_client.go b/sdk/resourcemanager/nginx/armnginx/wafpolicy_client.go new file mode 100644 index 000000000000..a4616d28a01f --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/wafpolicy_client.go @@ -0,0 +1,338 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armnginx + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// WafPolicyClient contains the methods for the WafPolicy group. +// Don't use this type directly, use NewWafPolicyClient() instead. +type WafPolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWafPolicyClient creates a new instance of WafPolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWafPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WafPolicyClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WafPolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create or update the Nginx Waf Policy for given Nginx deployment +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted NGINX deployment +// - wafPolicyName - The name of Waf Policy +// - body - The Nginx Deployment Waf Policy +// - options - WafPolicyClientBeginCreateOptions contains the optional parameters for the WafPolicyClient.BeginCreate method. +func (client *WafPolicyClient) BeginCreate(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, body DeploymentWafPolicy, options *WafPolicyClientBeginCreateOptions) (*runtime.Poller[WafPolicyClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, deploymentName, wafPolicyName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WafPolicyClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WafPolicyClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create or update the Nginx Waf Policy for given Nginx deployment +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *WafPolicyClient) create(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, body DeploymentWafPolicy, options *WafPolicyClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "WafPolicyClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, deploymentName, wafPolicyName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *WafPolicyClient) createCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, body DeploymentWafPolicy, _ *WafPolicyClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + if wafPolicyName == "" { + return nil, errors.New("parameter wafPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{wafPolicyName}", url.PathEscape(wafPolicyName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Reset the Nginx Waf Policy of given Nginx deployment to default +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted NGINX deployment +// - wafPolicyName - The name of Waf Policy +// - options - WafPolicyClientBeginDeleteOptions contains the optional parameters for the WafPolicyClient.BeginDelete method. +func (client *WafPolicyClient) BeginDelete(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, options *WafPolicyClientBeginDeleteOptions) (*runtime.Poller[WafPolicyClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, deploymentName, wafPolicyName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WafPolicyClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WafPolicyClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Reset the Nginx Waf Policy of given Nginx deployment to default +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *WafPolicyClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, options *WafPolicyClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "WafPolicyClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, deploymentName, wafPolicyName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WafPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, _ *WafPolicyClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + if wafPolicyName == "" { + return nil, errors.New("parameter wafPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{wafPolicyName}", url.PathEscape(wafPolicyName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get the Nginx Waf Policy of given Nginx deployment +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted NGINX deployment +// - wafPolicyName - The name of Waf Policy +// - options - WafPolicyClientGetOptions contains the optional parameters for the WafPolicyClient.Get method. +func (client *WafPolicyClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, options *WafPolicyClientGetOptions) (WafPolicyClientGetResponse, error) { + var err error + const operationName = "WafPolicyClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, deploymentName, wafPolicyName, options) + if err != nil { + return WafPolicyClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WafPolicyClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WafPolicyClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WafPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, wafPolicyName string, _ *WafPolicyClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies/{wafPolicyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + if wafPolicyName == "" { + return nil, errors.New("parameter wafPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{wafPolicyName}", url.PathEscape(wafPolicyName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WafPolicyClient) getHandleResponse(resp *http.Response) (WafPolicyClientGetResponse, error) { + result := WafPolicyClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentWafPolicy); err != nil { + return WafPolicyClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List Waf Policies of given Nginx deployment +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentName - The name of targeted NGINX deployment +// - options - WafPolicyClientListOptions contains the optional parameters for the WafPolicyClient.NewListPager method. +func (client *WafPolicyClient) NewListPager(resourceGroupName string, deploymentName string, options *WafPolicyClientListOptions) *runtime.Pager[WafPolicyClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WafPolicyClientListResponse]{ + More: func(page WafPolicyClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WafPolicyClientListResponse) (WafPolicyClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WafPolicyClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, deploymentName, options) + }, nil) + if err != nil { + return WafPolicyClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *WafPolicyClient) listCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *WafPolicyClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Nginx.NginxPlus/nginxDeployments/{deploymentName}/wafPolicies" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WafPolicyClient) listHandleResponse(resp *http.Response) (WafPolicyClientListResponse, error) { + result := WafPolicyClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentWafPolicyListResponse); err != nil { + return WafPolicyClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/nginx/armnginx/wafpolicy_client_example_test.go b/sdk/resourcemanager/nginx/armnginx/wafpolicy_client_example_test.go new file mode 100644 index 000000000000..406202567262 --- /dev/null +++ b/sdk/resourcemanager/nginx/armnginx/wafpolicy_client_example_test.go @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armnginx_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/nginx/armnginx/v3" + "log" +) + +// Generated from example definition: 2025-03-01-preview/WafPolicy_Create.json +func ExampleWafPolicyClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWafPolicyClient().BeginCreate(ctx, "myResourceGroup", "myDeployment", "myWafPolicy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.WafPolicyClientCreateResponse{ + // DeploymentWafPolicy: &armnginx.DeploymentWafPolicy{ + // Name: to.Ptr("myWafPolicy"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/wafPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/wafPolicies/myWafPolicy"), + // Properties: &armnginx.DeploymentWafPolicyProperties{ + // ApplyingState: &armnginx.DeploymentWafPolicyApplyingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyApplyingStatusCodeNotApplied), + // DisplayStatus: to.Ptr("Not Applied"), + // Time: to.Ptr("2025-03-02T10:05:00.000Z"), + // }, + // CompilingState: &armnginx.DeploymentWafPolicyCompilingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyCompilingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Succeeded"), + // Time: to.Ptr("2025-03-02T10:05:00.000Z"), + // }, + // Content: []byte("QUJDREVGR0g="), + // Filepath: to.Ptr("/etc/nginx/waf/policy.conf"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/WafPolicy_Delete.json +func ExampleWafPolicyClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWafPolicyClient().BeginDelete(ctx, "myResourceGroup", "myDeployment", "myWafPolicy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2025-03-01-preview/WafPolicy_Get.json +func ExampleWafPolicyClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWafPolicyClient().Get(ctx, "myResourceGroup", "myDeployment", "myWafPolicy", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armnginx.WafPolicyClientGetResponse{ + // DeploymentWafPolicy: &armnginx.DeploymentWafPolicy{ + // Name: to.Ptr("myWafPolicy"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/wafPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/wafPolicies/myWafPolicy"), + // Properties: &armnginx.DeploymentWafPolicyProperties{ + // ApplyingState: &armnginx.DeploymentWafPolicyApplyingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyApplyingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Policy Applied"), + // Time: to.Ptr("2025-03-02T10:05:00.000Z"), + // }, + // CompilingState: &armnginx.DeploymentWafPolicyCompilingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyCompilingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Compiled Successfully"), + // Time: to.Ptr("2025-03-02T10:00:00.000Z"), + // }, + // Content: []byte("QUJDREVGR0g="), + // Filepath: to.Ptr("/etc/nginx/waf/policy.conf"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/WafPolicy_List.json +func ExampleWafPolicyClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnginx.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWafPolicyClient().NewListPager("myResourceGroup", "myDeployment", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armnginx.WafPolicyClientListResponse{ + // DeploymentWafPolicyListResponse: armnginx.DeploymentWafPolicyListResponse{ + // NextLink: to.Ptr("https://management.azure.com/.../wafPolicies?api-version=2025-03-01-preview&$skiptoken=..."), + // Value: []*armnginx.DeploymentWafPolicyMetadata{ + // { + // Name: to.Ptr("wafPolicy1"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/wafPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/wafPolicies/wafPolicy1"), + // Properties: &armnginx.DeploymentWafPolicyMetadataProperties{ + // ApplyingState: &armnginx.DeploymentWafPolicyApplyingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyApplyingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Policy Applied"), + // Time: to.Ptr("2025-03-02T10:05:00.000Z"), + // }, + // CompilingState: &armnginx.DeploymentWafPolicyCompilingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyCompilingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Compiled Successfully"), + // Time: to.Ptr("2025-03-02T10:00:00.000Z"), + // }, + // Filepath: to.Ptr("/etc/nginx/waf/policy.conf"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("wafPolicy2"), + // Type: to.Ptr("Nginx.NginxPlus/nginxDeployments/wafPolicies"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Nginx.NginxPlus/nginxDeployments/myDeployment/wafPolicies/wafPolicy2"), + // Properties: &armnginx.DeploymentWafPolicyMetadataProperties{ + // ApplyingState: &armnginx.DeploymentWafPolicyApplyingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyApplyingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Policy Applied"), + // Time: to.Ptr("2025-03-02T10:05:00.000Z"), + // }, + // CompilingState: &armnginx.DeploymentWafPolicyCompilingStatus{ + // Code: to.Ptr(armnginx.NginxDeploymentWafPolicyCompilingStatusCodeSucceeded), + // DisplayStatus: to.Ptr("Compiled Successfully"), + // Time: to.Ptr("2025-03-02T10:00:00.000Z"), + // }, + // Filepath: to.Ptr("/etc/nginx/waf/policy.conf"), + // ProvisioningState: to.Ptr(armnginx.ProvisioningStateSucceeded), + // }, + // }, + // }, + // }, + // } + } +}