diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md b/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md index 936481ac695d..83b27bd14f70 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md @@ -1,5 +1,32 @@ # Release History +## 1.1.0-beta.1 (2024-05-23) +### Features Added + +- New enum type `PolicyType` with values `PolicyTypeWAF` +- New function `*ClientFactory.NewSecurityPoliciesInterfaceClient() *SecurityPoliciesInterfaceClient` +- New function `NewSecurityPoliciesInterfaceClient(string, azcore.TokenCredential, *arm.ClientOptions) (*SecurityPoliciesInterfaceClient, error)` +- New function `*SecurityPoliciesInterfaceClient.BeginCreateOrUpdate(context.Context, string, string, string, SecurityPolicy, *SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions) (*runtime.Poller[SecurityPoliciesInterfaceClientCreateOrUpdateResponse], error)` +- New function `*SecurityPoliciesInterfaceClient.BeginDelete(context.Context, string, string, string, *SecurityPoliciesInterfaceClientBeginDeleteOptions) (*runtime.Poller[SecurityPoliciesInterfaceClientDeleteResponse], error)` +- New function `*SecurityPoliciesInterfaceClient.Get(context.Context, string, string, string, *SecurityPoliciesInterfaceClientGetOptions) (SecurityPoliciesInterfaceClientGetResponse, error)` +- New function `*SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager(string, string, *SecurityPoliciesInterfaceClientListByTrafficControllerOptions) *runtime.Pager[SecurityPoliciesInterfaceClientListByTrafficControllerResponse]` +- New function `*SecurityPoliciesInterfaceClient.Update(context.Context, string, string, string, SecurityPolicyUpdate, *SecurityPoliciesInterfaceClientUpdateOptions) (SecurityPoliciesInterfaceClientUpdateResponse, error)` +- New struct `SecurityPolicy` +- New struct `SecurityPolicyConfigurations` +- New struct `SecurityPolicyConfigurationsUpdate` +- New struct `SecurityPolicyListResult` +- New struct `SecurityPolicyProperties` +- New struct `SecurityPolicyUpdate` +- New struct `SecurityPolicyUpdateProperties` +- New struct `TrafficControllerUpdateProperties` +- New struct `WafPolicy` +- New struct `WafPolicyUpdate` +- New struct `WafSecurityPolicy` +- New struct `WafSecurityPolicyUpdate` +- New field `SecurityPolicies`, `SecurityPolicyConfigurations` in struct `TrafficControllerProperties` +- New field `Properties` in struct `TrafficControllerUpdate` + + ## 1.0.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go index 98868c7284e5..40fdc2d44dd2 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go @@ -46,7 +46,7 @@ func NewAssociationsInterfaceClient(subscriptionID string, credential azcore.Tok // BeginCreateOrUpdate - Create a Association // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - associationName - Name of Association @@ -74,7 +74,7 @@ func (client *AssociationsInterfaceClient) BeginCreateOrUpdate(ctx context.Conte // CreateOrUpdate - Create a Association // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview func (client *AssociationsInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, resource Association, options *AssociationsInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "AssociationsInterfaceClient.BeginCreateOrUpdate" @@ -120,7 +120,7 @@ func (client *AssociationsInterfaceClient) createOrUpdateCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, resource); err != nil { @@ -132,7 +132,7 @@ func (client *AssociationsInterfaceClient) createOrUpdateCreateRequest(ctx conte // BeginDelete - Delete a Association // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - associationName - Name of Association @@ -159,7 +159,7 @@ func (client *AssociationsInterfaceClient) BeginDelete(ctx context.Context, reso // Delete - Delete a Association // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview func (client *AssociationsInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, options *AssociationsInterfaceClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "AssociationsInterfaceClient.BeginDelete" @@ -174,7 +174,7 @@ func (client *AssociationsInterfaceClient) deleteOperation(ctx context.Context, 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 } @@ -205,7 +205,7 @@ func (client *AssociationsInterfaceClient) deleteCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -214,7 +214,7 @@ func (client *AssociationsInterfaceClient) deleteCreateRequest(ctx context.Conte // Get - Get a Association // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - associationName - Name of Association @@ -266,7 +266,7 @@ func (client *AssociationsInterfaceClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -283,7 +283,7 @@ func (client *AssociationsInterfaceClient) getHandleResponse(resp *http.Response // NewListByTrafficControllerPager - List Association resources by TrafficController // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - options - AssociationsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the AssociationsInterfaceClient.NewListByTrafficControllerPager @@ -331,7 +331,7 @@ func (client *AssociationsInterfaceClient) listByTrafficControllerCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -349,7 +349,7 @@ func (client *AssociationsInterfaceClient) listByTrafficControllerHandleResponse // Update - Update a Association // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - associationName - Name of Association @@ -402,7 +402,7 @@ func (client *AssociationsInterfaceClient) updateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, properties); err != nil { diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go deleted file mode 100644 index 2cba5d9ea1ef..000000000000 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go +++ /dev/null @@ -1,198 +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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armservicenetworking_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationsGet.json -func ExampleAssociationsInterfaceClient_NewListByTrafficControllerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssociationsInterfaceClient().NewListByTrafficControllerPager("rg1", "tc1", 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.AssociationListResult = armservicenetworking.AssociationListResult{ - // Value: []*armservicenetworking.Association{ - // { - // Name: to.Ptr("as1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/associations/as1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.AssociationProperties{ - // AssociationType: to.Ptr(armservicenetworking.AssociationTypeSubnets), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // Subnet: &armservicenetworking.AssociationSubnet{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationGet.json -func ExampleAssociationsInterfaceClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssociationsInterfaceClient().Get(ctx, "rg1", "tc1", "as1", 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.Association = armservicenetworking.Association{ - // Name: to.Ptr("as1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/associations/as1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.AssociationProperties{ - // AssociationType: to.Ptr(armservicenetworking.AssociationTypeSubnets), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // Subnet: &armservicenetworking.AssociationSubnet{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationPut.json -func ExampleAssociationsInterfaceClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssociationsInterfaceClient().BeginCreateOrUpdate(ctx, "rg1", "tc1", "as1", armservicenetworking.Association{ - Location: to.Ptr("NorthCentralUS"), - Properties: &armservicenetworking.AssociationProperties{ - AssociationType: to.Ptr(armservicenetworking.AssociationTypeSubnets), - Subnet: &armservicenetworking.AssociationSubnet{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - }, - }, - }, 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.Association = armservicenetworking.Association{ - // Name: to.Ptr("associatedvnet-1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/associations/as1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.AssociationProperties{ - // AssociationType: to.Ptr(armservicenetworking.AssociationTypeSubnets), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // Subnet: &armservicenetworking.AssociationSubnet{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationPatch.json -func ExampleAssociationsInterfaceClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssociationsInterfaceClient().Update(ctx, "rg1", "tc1", "as1", armservicenetworking.AssociationUpdate{ - Properties: &armservicenetworking.AssociationUpdateProperties{ - AssociationType: to.Ptr(armservicenetworking.AssociationTypeSubnets), - Subnet: &armservicenetworking.AssociationSubnetUpdate{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - }, - }, - }, 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.Association = armservicenetworking.Association{ - // Name: to.Ptr("as1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), - // ID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/associations/as1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.AssociationProperties{ - // AssociationType: to.Ptr(armservicenetworking.AssociationTypeSubnets), - // Subnet: &armservicenetworking.AssociationSubnet{ - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationDelete.json -func ExampleAssociationsInterfaceClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssociationsInterfaceClient().BeginDelete(ctx, "rg1", "tc1", "as1", 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) - } -} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md b/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md index a42c041d31f9..1d90593fc787 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/servicenetworking/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/servicenetworking/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 -tag: package-2023-11-01 +module-version: 1.1.0-beta.1 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go index e3e94fcfa2f2..b3ec6ff8b8ba 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go @@ -17,8 +17,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,36 +26,51 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAssociationsInterfaceClient creates a new instance of AssociationsInterfaceClient. func (c *ClientFactory) NewAssociationsInterfaceClient() *AssociationsInterfaceClient { - subClient, _ := NewAssociationsInterfaceClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AssociationsInterfaceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewFrontendsInterfaceClient creates a new instance of FrontendsInterfaceClient. func (c *ClientFactory) NewFrontendsInterfaceClient() *FrontendsInterfaceClient { - subClient, _ := NewFrontendsInterfaceClient(c.subscriptionID, c.credential, c.options) - return subClient + return &FrontendsInterfaceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } +} + +// NewSecurityPoliciesInterfaceClient creates a new instance of SecurityPoliciesInterfaceClient. +func (c *ClientFactory) NewSecurityPoliciesInterfaceClient() *SecurityPoliciesInterfaceClient { + return &SecurityPoliciesInterfaceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTrafficControllerInterfaceClient creates a new instance of TrafficControllerInterfaceClient. func (c *ClientFactory) NewTrafficControllerInterfaceClient() *TrafficControllerInterfaceClient { - subClient, _ := NewTrafficControllerInterfaceClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TrafficControllerInterfaceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go index 4a6d266648f2..3ea9e0d96078 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go @@ -10,7 +10,7 @@ package armservicenetworking const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0-beta.1" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -27,9 +27,11 @@ func PossibleActionTypeValues() []ActionType { } } +// AssociationType - Association Type Enum type AssociationType string const ( + // AssociationTypeSubnets - Association of Type Subnet AssociationTypeSubnets AssociationType = "subnets" ) @@ -79,16 +81,39 @@ func PossibleOriginValues() []Origin { } } +// PolicyType - Policy Type of the Security Policy +type PolicyType string + +const ( + // PolicyTypeWAF - Policy of Type WAF + PolicyTypeWAF PolicyType = "waf" +) + +// PossiblePolicyTypeValues returns the possible values for the PolicyType const type. +func PossiblePolicyTypeValues() []PolicyType { + return []PolicyType{ + PolicyTypeWAF, + } +} + +// ProvisioningState - Resource Provisioning State Enum type ProvisioningState string const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateAccepted - Resource in Accepted State + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource in Canceled State + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - Resource in Deleting State + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource in Failed State + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - Resource in Provisioning State ProvisioningStateProvisioning ProvisioningState = "Provisioning" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateSucceeded - Resource in Succeeded State + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Resource in Updating State + ProvisioningStateUpdating ProvisioningState = "Updating" ) // PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/associationsinterface_server.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/associationsinterface_server.go index 762cd7853950..7e9364abd690 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/associationsinterface_server.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/associationsinterface_server.go @@ -29,7 +29,7 @@ type AssociationsInterfaceServer struct { BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, resource armservicenetworking.Association, options *armservicenetworking.AssociationsInterfaceClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armservicenetworking.AssociationsInterfaceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method AssociationsInterfaceClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, options *armservicenetworking.AssociationsInterfaceClientBeginDeleteOptions) (resp azfake.PollerResponder[armservicenetworking.AssociationsInterfaceClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method AssociationsInterfaceClient.Get @@ -188,9 +188,9 @@ func (a *AssociationsInterfaceServerTransport) dispatchBeginDelete(req *http.Req return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { a.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { a.beginDelete.remove(req) diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/frontendsinterface_server.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/frontendsinterface_server.go index 628e4af7a79f..74480f8fa6e5 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/frontendsinterface_server.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/frontendsinterface_server.go @@ -29,7 +29,7 @@ type FrontendsInterfaceServer struct { BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, resource armservicenetworking.Frontend, options *armservicenetworking.FrontendsInterfaceClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armservicenetworking.FrontendsInterfaceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method FrontendsInterfaceClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, options *armservicenetworking.FrontendsInterfaceClientBeginDeleteOptions) (resp azfake.PollerResponder[armservicenetworking.FrontendsInterfaceClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method FrontendsInterfaceClient.Get @@ -188,9 +188,9 @@ func (f *FrontendsInterfaceServerTransport) dispatchBeginDelete(req *http.Reques return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { f.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { f.beginDelete.remove(req) diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/securitypoliciesinterface_server.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/securitypoliciesinterface_server.go new file mode 100644 index 000000000000..71b054235b84 --- /dev/null +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/securitypoliciesinterface_server.go @@ -0,0 +1,319 @@ +//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 ( + "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/servicenetworking/armservicenetworking" + "net/http" + "net/url" + "regexp" +) + +// SecurityPoliciesInterfaceServer is a fake server for instances of the armservicenetworking.SecurityPoliciesInterfaceClient type. +type SecurityPoliciesInterfaceServer struct { + // BeginCreateOrUpdate is the fake for method SecurityPoliciesInterfaceClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, resource armservicenetworking.SecurityPolicy, options *armservicenetworking.SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armservicenetworking.SecurityPoliciesInterfaceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SecurityPoliciesInterfaceClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *armservicenetworking.SecurityPoliciesInterfaceClientBeginDeleteOptions) (resp azfake.PollerResponder[armservicenetworking.SecurityPoliciesInterfaceClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SecurityPoliciesInterfaceClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *armservicenetworking.SecurityPoliciesInterfaceClientGetOptions) (resp azfake.Responder[armservicenetworking.SecurityPoliciesInterfaceClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByTrafficControllerPager is the fake for method SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager + // HTTP status codes to indicate success: http.StatusOK + NewListByTrafficControllerPager func(resourceGroupName string, trafficControllerName string, options *armservicenetworking.SecurityPoliciesInterfaceClientListByTrafficControllerOptions) (resp azfake.PagerResponder[armservicenetworking.SecurityPoliciesInterfaceClientListByTrafficControllerResponse]) + + // Update is the fake for method SecurityPoliciesInterfaceClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, properties armservicenetworking.SecurityPolicyUpdate, options *armservicenetworking.SecurityPoliciesInterfaceClientUpdateOptions) (resp azfake.Responder[armservicenetworking.SecurityPoliciesInterfaceClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewSecurityPoliciesInterfaceServerTransport creates a new instance of SecurityPoliciesInterfaceServerTransport with the provided implementation. +// The returned SecurityPoliciesInterfaceServerTransport instance is connected to an instance of armservicenetworking.SecurityPoliciesInterfaceClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSecurityPoliciesInterfaceServerTransport(srv *SecurityPoliciesInterfaceServer) *SecurityPoliciesInterfaceServerTransport { + return &SecurityPoliciesInterfaceServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armservicenetworking.SecurityPoliciesInterfaceClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armservicenetworking.SecurityPoliciesInterfaceClientDeleteResponse]](), + newListByTrafficControllerPager: newTracker[azfake.PagerResponder[armservicenetworking.SecurityPoliciesInterfaceClientListByTrafficControllerResponse]](), + } +} + +// SecurityPoliciesInterfaceServerTransport connects instances of armservicenetworking.SecurityPoliciesInterfaceClient to instances of SecurityPoliciesInterfaceServer. +// Don't use this type directly, use NewSecurityPoliciesInterfaceServerTransport instead. +type SecurityPoliciesInterfaceServerTransport struct { + srv *SecurityPoliciesInterfaceServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armservicenetworking.SecurityPoliciesInterfaceClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armservicenetworking.SecurityPoliciesInterfaceClientDeleteResponse]] + newListByTrafficControllerPager *tracker[azfake.PagerResponder[armservicenetworking.SecurityPoliciesInterfaceClientListByTrafficControllerResponse]] +} + +// Do implements the policy.Transporter interface for SecurityPoliciesInterfaceServerTransport. +func (s *SecurityPoliciesInterfaceServerTransport) 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")} + } + + var resp *http.Response + var err error + + switch method { + case "SecurityPoliciesInterfaceClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "SecurityPoliciesInterfaceClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "SecurityPoliciesInterfaceClient.Get": + resp, err = s.dispatchGet(req) + case "SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager": + resp, err = s.dispatchNewListByTrafficControllerPager(req) + case "SecurityPoliciesInterfaceClient.Update": + resp, err = s.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SecurityPoliciesInterfaceServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceNetworking/trafficControllers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/securityPolicy/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armservicenetworking.SecurityPolicy](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + trafficControllerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("trafficControllerName")]) + if err != nil { + return nil, err + } + securityPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("securityPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, trafficControllerNameParam, securityPolicyNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *SecurityPoliciesInterfaceServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceNetworking/trafficControllers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/securityPolicy/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || 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 + } + trafficControllerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("trafficControllerName")]) + if err != nil { + return nil, err + } + securityPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("securityPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, trafficControllerNameParam, securityPolicyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *SecurityPoliciesInterfaceServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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/Microsoft\.ServiceNetworking/trafficControllers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/securityPolicy/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || 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 + } + trafficControllerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("trafficControllerName")]) + if err != nil { + return nil, err + } + securityPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("securityPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, trafficControllerNameParam, securityPolicyNameParam, 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).SecurityPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SecurityPoliciesInterfaceServerTransport) dispatchNewListByTrafficControllerPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByTrafficControllerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByTrafficControllerPager not implemented")} + } + newListByTrafficControllerPager := s.newListByTrafficControllerPager.get(req) + if newListByTrafficControllerPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceNetworking/trafficControllers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/securityPolicy` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + 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 + } + trafficControllerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("trafficControllerName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByTrafficControllerPager(resourceGroupNameParam, trafficControllerNameParam, nil) + newListByTrafficControllerPager = &resp + s.newListByTrafficControllerPager.add(req, newListByTrafficControllerPager) + server.PagerResponderInjectNextLinks(newListByTrafficControllerPager, req, func(page *armservicenetworking.SecurityPoliciesInterfaceClientListByTrafficControllerResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByTrafficControllerPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByTrafficControllerPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByTrafficControllerPager) { + s.newListByTrafficControllerPager.remove(req) + } + return resp, nil +} + +func (s *SecurityPoliciesInterfaceServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if s.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceNetworking/trafficControllers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/securityPolicy/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armservicenetworking.SecurityPolicyUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + trafficControllerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("trafficControllerName")]) + if err != nil { + return nil, err + } + securityPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("securityPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, trafficControllerNameParam, securityPolicyNameParam, body, 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).SecurityPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/server_factory.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/server_factory.go index c5efb1fb7ba1..eff1829529d6 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/server_factory.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/server_factory.go @@ -22,6 +22,7 @@ type ServerFactory struct { AssociationsInterfaceServer AssociationsInterfaceServer FrontendsInterfaceServer FrontendsInterfaceServer OperationsServer OperationsServer + SecurityPoliciesInterfaceServer SecurityPoliciesInterfaceServer TrafficControllerInterfaceServer TrafficControllerInterfaceServer } @@ -42,6 +43,7 @@ type ServerFactoryTransport struct { trAssociationsInterfaceServer *AssociationsInterfaceServerTransport trFrontendsInterfaceServer *FrontendsInterfaceServerTransport trOperationsServer *OperationsServerTransport + trSecurityPoliciesInterfaceServer *SecurityPoliciesInterfaceServerTransport trTrafficControllerInterfaceServer *TrafficControllerInterfaceServerTransport } @@ -71,6 +73,11 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "SecurityPoliciesInterfaceClient": + initServer(s, &s.trSecurityPoliciesInterfaceServer, func() *SecurityPoliciesInterfaceServerTransport { + return NewSecurityPoliciesInterfaceServerTransport(&s.srv.SecurityPoliciesInterfaceServer) + }) + resp, err = s.trSecurityPoliciesInterfaceServer.Do(req) case "TrafficControllerInterfaceClient": initServer(s, &s.trTrafficControllerInterfaceServer, func() *TrafficControllerInterfaceServerTransport { return NewTrafficControllerInterfaceServerTransport(&s.srv.TrafficControllerInterfaceServer) diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/time_rfc3339.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/time_rfc3339.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // 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+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + 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 @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + 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 { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + 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)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { 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 @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/trafficcontrollerinterface_server.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/trafficcontrollerinterface_server.go index 993d37add085..6934459ff187 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/trafficcontrollerinterface_server.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/fake/trafficcontrollerinterface_server.go @@ -29,7 +29,7 @@ type TrafficControllerInterfaceServer struct { BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, trafficControllerName string, resource armservicenetworking.TrafficController, options *armservicenetworking.TrafficControllerInterfaceClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armservicenetworking.TrafficControllerInterfaceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method TrafficControllerInterfaceClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, trafficControllerName string, options *armservicenetworking.TrafficControllerInterfaceClientBeginDeleteOptions) (resp azfake.PollerResponder[armservicenetworking.TrafficControllerInterfaceClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method TrafficControllerInterfaceClient.Get @@ -188,9 +188,9 @@ func (t *TrafficControllerInterfaceServerTransport) dispatchBeginDelete(req *htt return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { t.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { t.beginDelete.remove(req) diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go index b69b46d6c449..90015a6dbaf3 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go @@ -46,7 +46,7 @@ func NewFrontendsInterfaceClient(subscriptionID string, credential azcore.TokenC // BeginCreateOrUpdate - Create a Frontend // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - frontendName - Frontends @@ -74,7 +74,7 @@ func (client *FrontendsInterfaceClient) BeginCreateOrUpdate(ctx context.Context, // CreateOrUpdate - Create a Frontend // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview func (client *FrontendsInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, resource Frontend, options *FrontendsInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "FrontendsInterfaceClient.BeginCreateOrUpdate" @@ -120,7 +120,7 @@ func (client *FrontendsInterfaceClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, resource); err != nil { @@ -132,7 +132,7 @@ func (client *FrontendsInterfaceClient) createOrUpdateCreateRequest(ctx context. // BeginDelete - Delete a Frontend // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - frontendName - Frontends @@ -159,7 +159,7 @@ func (client *FrontendsInterfaceClient) BeginDelete(ctx context.Context, resourc // Delete - Delete a Frontend // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview func (client *FrontendsInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, options *FrontendsInterfaceClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "FrontendsInterfaceClient.BeginDelete" @@ -174,7 +174,7 @@ func (client *FrontendsInterfaceClient) deleteOperation(ctx context.Context, res 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 } @@ -205,7 +205,7 @@ func (client *FrontendsInterfaceClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -214,7 +214,7 @@ func (client *FrontendsInterfaceClient) deleteCreateRequest(ctx context.Context, // Get - Get a Frontend // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - frontendName - Frontends @@ -265,7 +265,7 @@ func (client *FrontendsInterfaceClient) getCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -282,7 +282,7 @@ func (client *FrontendsInterfaceClient) getHandleResponse(resp *http.Response) ( // NewListByTrafficControllerPager - List Frontend resources by TrafficController // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - options - FrontendsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the FrontendsInterfaceClient.NewListByTrafficControllerPager @@ -330,7 +330,7 @@ func (client *FrontendsInterfaceClient) listByTrafficControllerCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -348,7 +348,7 @@ func (client *FrontendsInterfaceClient) listByTrafficControllerHandleResponse(re // Update - Update a Frontend // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - frontendName - Frontends @@ -401,7 +401,7 @@ func (client *FrontendsInterfaceClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, properties); err != nil { diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go deleted file mode 100644 index 261369fbe915..000000000000 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go +++ /dev/null @@ -1,175 +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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armservicenetworking_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendsGet.json -func ExampleFrontendsInterfaceClient_NewListByTrafficControllerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFrontendsInterfaceClient().NewListByTrafficControllerPager("rg1", "tc1", 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.FrontendListResult = armservicenetworking.FrontendListResult{ - // Value: []*armservicenetworking.Frontend{ - // { - // Name: to.Ptr("fe1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.FrontendProperties{ - // Fqdn: to.Ptr("test.net"), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendGet.json -func ExampleFrontendsInterfaceClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFrontendsInterfaceClient().Get(ctx, "rg1", "tc1", "fe1", 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.Frontend = armservicenetworking.Frontend{ - // Name: to.Ptr("fe1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.FrontendProperties{ - // Fqdn: to.Ptr("test.net"), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendPut.json -func ExampleFrontendsInterfaceClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFrontendsInterfaceClient().BeginCreateOrUpdate(ctx, "rg1", "tc1", "fe1", armservicenetworking.Frontend{ - Location: to.Ptr("NorthCentralUS"), - Properties: &armservicenetworking.FrontendProperties{}, - }, 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.Frontend = armservicenetworking.Frontend{ - // Name: to.Ptr("fe1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.FrontendProperties{ - // Fqdn: to.Ptr("test.net"), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendPatch.json -func ExampleFrontendsInterfaceClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFrontendsInterfaceClient().Update(ctx, "rg1", "tc1", "fe1", armservicenetworking.FrontendUpdate{}, 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.Frontend = armservicenetworking.Frontend{ - // Name: to.Ptr("fe1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // Location: to.Ptr("NorthCentralUS"), - // Properties: &armservicenetworking.FrontendProperties{ - // Fqdn: to.Ptr("test.net"), - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendDelete.json -func ExampleFrontendsInterfaceClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFrontendsInterfaceClient().BeginDelete(ctx, "rg1", "tc1", "fe1", 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) - } -} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod index 84ad36603eab..7cabfad3c6d7 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/a go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // 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.22.0 // indirect golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum index 453385ef9f88..ffdff03203f8 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 h1:E+OJmp2tPvt1W+amx48v1eqbjDYsgN+RzP4q16yV5eM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 h1:FDif4R1+UUR+00q6wquyX90K7A8dN+R5E8GEadoP7sU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2/go.mod h1:aiYBYui4BJ/BJCAIKs92XiPyQfTaBWqvHujDwKb6CBU= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 h1:rTfKOCZGy5ViVrlA74ZPE99a+SgoEE2K/yg3RyW9dFA= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0/go.mod h1:4OG6tQ9EOP/MT0NMjDlRzWoVFxfu9rN9B2X+tlSVktg= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -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/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go index 2111d1db8771..41e53f531da3 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go @@ -85,7 +85,7 @@ type AssociationUpdateProperties struct { Subnet *AssociationSubnetUpdate } -// Frontend Subresource of Traffic Controller. +// Frontend Sub Resource of Traffic Controller. type Frontend struct { // REQUIRED; The geo-location where the resource lives Location *string @@ -188,6 +188,78 @@ type ResourceID struct { ID *string } +// SecurityPolicy Subresource of Traffic Controller. +type SecurityPolicy struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *SecurityPolicyProperties + + // Resource tags. + Tags map[string]*string + + // 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 +} + +// SecurityPolicyConfigurations Subresource of Traffic Controller. +type SecurityPolicyConfigurations struct { + // Contains reference to a WAF-type security policy that is applied at the Traffic Controller level. + WafSecurityPolicy *WafSecurityPolicy +} + +// SecurityPolicyConfigurationsUpdate - SecurityPolicyConfigurations Subresource of Traffic Controller. +type SecurityPolicyConfigurationsUpdate struct { + // Contains reference to a WAF-type security policy that is applied at the Traffic Controller level. + WafSecurityPolicy *WafSecurityPolicyUpdate +} + +// SecurityPolicyListResult - The response of a SecurityPolicy list operation. +type SecurityPolicyListResult struct { + // REQUIRED; The SecurityPolicy items on this page + Value []*SecurityPolicy + + // The link to the next page of items + NextLink *string +} + +// SecurityPolicyProperties - SecurityPolicy Properties. +type SecurityPolicyProperties struct { + // Web Application Firewall Policy of the Traffic Controller Security Policy + WafPolicy *WafPolicy + + // READ-ONLY; Type of the Traffic Controller Security Policy + PolicyType *PolicyType + + // READ-ONLY; Provisioning State of Traffic Controller SecurityPolicy Resource + ProvisioningState *ProvisioningState +} + +// SecurityPolicyUpdate - The type used for update operations of the SecurityPolicy. +type SecurityPolicyUpdate struct { + // The updatable properties of the SecurityPolicy. + Properties *SecurityPolicyUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// SecurityPolicyUpdateProperties - The updatable properties of the SecurityPolicy. +type SecurityPolicyUpdateProperties struct { + // Web Application Firewall Policy of the Traffic Controller Security Policy + WafPolicy *WafPolicyUpdate +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -244,6 +316,9 @@ type TrafficControllerListResult struct { // TrafficControllerProperties - Traffic Controller Properties. type TrafficControllerProperties struct { + // Security Policy Configuration + SecurityPolicyConfigurations *SecurityPolicyConfigurations + // READ-ONLY; Associations References List Associations []*ResourceID @@ -255,10 +330,46 @@ type TrafficControllerProperties struct { // READ-ONLY; The status of the last operation. ProvisioningState *ProvisioningState + + // READ-ONLY; Security Policies References List + SecurityPolicies []*ResourceID } // TrafficControllerUpdate - The type used for update operations of the TrafficController. type TrafficControllerUpdate struct { + // The updatable properties of the TrafficController. + Properties *TrafficControllerUpdateProperties + // Resource tags. Tags map[string]*string } + +// TrafficControllerUpdateProperties - The updatable properties of the TrafficController. +type TrafficControllerUpdateProperties struct { + // Security Policy Configuration + SecurityPolicyConfigurations *SecurityPolicyConfigurationsUpdate +} + +// WafPolicy - Web Application Firewall Policy +type WafPolicy struct { + // REQUIRED; Resource ID of the WAF + ID *string +} + +// WafPolicyUpdate - Web Application Firewall Policy +type WafPolicyUpdate struct { + // Resource ID of the WAF + ID *string +} + +// WafSecurityPolicy - Web Application Firewall Security Policy +type WafSecurityPolicy struct { + // REQUIRED; Resource ID of the Waf Security Policy + ID *string +} + +// WafSecurityPolicyUpdate - Web Application Firewall Security Policy +type WafSecurityPolicyUpdate struct { + // Resource ID of the Waf Security Policy + ID *string +} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go index e595b80706d0..bbc64dfc3412 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go @@ -528,6 +528,235 @@ func (r *ResourceID) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicy. +func (s SecurityPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicy. +func (s *SecurityPolicy) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyConfigurations. +func (s SecurityPolicyConfigurations) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "wafSecurityPolicy", s.WafSecurityPolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyConfigurations. +func (s *SecurityPolicyConfigurations) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "wafSecurityPolicy": + err = unpopulate(val, "WafSecurityPolicy", &s.WafSecurityPolicy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyConfigurationsUpdate. +func (s SecurityPolicyConfigurationsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "wafSecurityPolicy", s.WafSecurityPolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyConfigurationsUpdate. +func (s *SecurityPolicyConfigurationsUpdate) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "wafSecurityPolicy": + err = unpopulate(val, "WafSecurityPolicy", &s.WafSecurityPolicy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyListResult. +func (s SecurityPolicyListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyListResult. +func (s *SecurityPolicyListResult) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyProperties. +func (s SecurityPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "policyType", s.PolicyType) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "wafPolicy", s.WafPolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyProperties. +func (s *SecurityPolicyProperties) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "policyType": + err = unpopulate(val, "PolicyType", &s.PolicyType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "wafPolicy": + err = unpopulate(val, "WafPolicy", &s.WafPolicy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyUpdate. +func (s SecurityPolicyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyUpdate. +func (s *SecurityPolicyUpdate) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyUpdateProperties. +func (s SecurityPolicyUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "wafPolicy", s.WafPolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyUpdateProperties. +func (s *SecurityPolicyUpdateProperties) 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", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "wafPolicy": + err = unpopulate(val, "WafPolicy", &s.WafPolicy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -664,6 +893,8 @@ func (t TrafficControllerProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "configurationEndpoints", t.ConfigurationEndpoints) populate(objectMap, "frontends", t.Frontends) populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "securityPolicies", t.SecurityPolicies) + populate(objectMap, "securityPolicyConfigurations", t.SecurityPolicyConfigurations) return json.Marshal(objectMap) } @@ -688,6 +919,12 @@ func (t *TrafficControllerProperties) UnmarshalJSON(data []byte) error { case "provisioningState": err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) delete(rawMsg, key) + case "securityPolicies": + err = unpopulate(val, "SecurityPolicies", &t.SecurityPolicies) + delete(rawMsg, key) + case "securityPolicyConfigurations": + err = unpopulate(val, "SecurityPolicyConfigurations", &t.SecurityPolicyConfigurations) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -699,6 +936,7 @@ func (t *TrafficControllerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficControllerUpdate. func (t TrafficControllerUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) } @@ -712,6 +950,9 @@ func (t *TrafficControllerUpdate) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &t.Tags) delete(rawMsg, key) @@ -723,6 +964,141 @@ func (t *TrafficControllerUpdate) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TrafficControllerUpdateProperties. +func (t TrafficControllerUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "securityPolicyConfigurations", t.SecurityPolicyConfigurations) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrafficControllerUpdateProperties. +func (t *TrafficControllerUpdateProperties) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "securityPolicyConfigurations": + err = unpopulate(val, "SecurityPolicyConfigurations", &t.SecurityPolicyConfigurations) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WafPolicy. +func (w WafPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WafPolicy. +func (w *WafPolicy) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WafPolicyUpdate. +func (w WafPolicyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WafPolicyUpdate. +func (w *WafPolicyUpdate) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WafSecurityPolicy. +func (w WafSecurityPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WafSecurityPolicy. +func (w *WafSecurityPolicy) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WafSecurityPolicyUpdate. +func (w WafSecurityPolicyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WafSecurityPolicyUpdate. +func (w *WafSecurityPolicyUpdate) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return @@ -734,7 +1110,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go index 1000bf18cf09..ae25aca1116d 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List the operations for the provider // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-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]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client_example_test.go deleted file mode 100644 index 734431ef05cd..000000000000 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client_example_test.go +++ /dev/null @@ -1,57 +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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armservicenetworking_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/OperationsList.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 := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(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.OperationListResult = armservicenetworking.OperationListResult{ - // Value: []*armservicenetworking.Operation{ - // { - // Name: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/read"), - // Display: &armservicenetworking.OperationDisplay{ - // Description: to.Ptr("Traffic Controller is a L7 Load Balancing solution for a Multi Cluster setup"), - // Operation: to.Ptr("Get Traffic Controller configuration"), - // Provider: to.Ptr("Microsoft Service Networking"), - // Resource: to.Ptr("Traffic Controller"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr(armservicenetworking.OriginUserSystem), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/options.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/options.go index 35b047221323..c25d85b968fa 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/options.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/options.go @@ -73,6 +73,38 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.BeginCreateOrUpdate +// method. +type SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SecurityPoliciesInterfaceClientBeginDeleteOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.BeginDelete +// method. +type SecurityPoliciesInterfaceClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SecurityPoliciesInterfaceClientGetOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.Get +// method. +type SecurityPoliciesInterfaceClientGetOptions struct { + // placeholder for future optional parameters +} + +// SecurityPoliciesInterfaceClientListByTrafficControllerOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager +// method. +type SecurityPoliciesInterfaceClientListByTrafficControllerOptions struct { + // placeholder for future optional parameters +} + +// SecurityPoliciesInterfaceClientUpdateOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.Update +// method. +type SecurityPoliciesInterfaceClientUpdateOptions struct { + // placeholder for future optional parameters +} + // TrafficControllerInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the TrafficControllerInterfaceClient.BeginCreateOrUpdate // method. type TrafficControllerInterfaceClientBeginCreateOrUpdateOptions struct { diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/responses.go similarity index 76% rename from sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go rename to sdk/resourcemanager/servicenetworking/armservicenetworking/responses.go index 3cd51f53b009..6bfb68611c48 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/responses.go @@ -39,7 +39,7 @@ type AssociationsInterfaceClientUpdateResponse struct { // FrontendsInterfaceClientCreateOrUpdateResponse contains the response from method FrontendsInterfaceClient.BeginCreateOrUpdate. type FrontendsInterfaceClientCreateOrUpdateResponse struct { - // Frontend Subresource of Traffic Controller. + // Frontend Sub Resource of Traffic Controller. Frontend } @@ -50,7 +50,7 @@ type FrontendsInterfaceClientDeleteResponse struct { // FrontendsInterfaceClientGetResponse contains the response from method FrontendsInterfaceClient.Get. type FrontendsInterfaceClientGetResponse struct { - // Frontend Subresource of Traffic Controller. + // Frontend Sub Resource of Traffic Controller. Frontend } @@ -62,7 +62,7 @@ type FrontendsInterfaceClientListByTrafficControllerResponse struct { // FrontendsInterfaceClientUpdateResponse contains the response from method FrontendsInterfaceClient.Update. type FrontendsInterfaceClientUpdateResponse struct { - // Frontend Subresource of Traffic Controller. + // Frontend Sub Resource of Traffic Controller. Frontend } @@ -72,6 +72,35 @@ type OperationsClientListResponse struct { OperationListResult } +// SecurityPoliciesInterfaceClientCreateOrUpdateResponse contains the response from method SecurityPoliciesInterfaceClient.BeginCreateOrUpdate. +type SecurityPoliciesInterfaceClientCreateOrUpdateResponse struct { + // SecurityPolicy Subresource of Traffic Controller. + SecurityPolicy +} + +// SecurityPoliciesInterfaceClientDeleteResponse contains the response from method SecurityPoliciesInterfaceClient.BeginDelete. +type SecurityPoliciesInterfaceClientDeleteResponse struct { + // placeholder for future response values +} + +// SecurityPoliciesInterfaceClientGetResponse contains the response from method SecurityPoliciesInterfaceClient.Get. +type SecurityPoliciesInterfaceClientGetResponse struct { + // SecurityPolicy Subresource of Traffic Controller. + SecurityPolicy +} + +// SecurityPoliciesInterfaceClientListByTrafficControllerResponse contains the response from method SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager. +type SecurityPoliciesInterfaceClientListByTrafficControllerResponse struct { + // The response of a SecurityPolicy list operation. + SecurityPolicyListResult +} + +// SecurityPoliciesInterfaceClientUpdateResponse contains the response from method SecurityPoliciesInterfaceClient.Update. +type SecurityPoliciesInterfaceClientUpdateResponse struct { + // SecurityPolicy Subresource of Traffic Controller. + SecurityPolicy +} + // TrafficControllerInterfaceClientCreateOrUpdateResponse contains the response from method TrafficControllerInterfaceClient.BeginCreateOrUpdate. type TrafficControllerInterfaceClientCreateOrUpdateResponse struct { // Concrete tracked resource types can be created by aliasing this type using a specific property type. diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/securitypoliciesinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/securitypoliciesinterface_client.go new file mode 100644 index 000000000000..aa1d95e8f095 --- /dev/null +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/securitypoliciesinterface_client.go @@ -0,0 +1,421 @@ +//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 armservicenetworking + +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" +) + +// SecurityPoliciesInterfaceClient contains the methods for the SecurityPoliciesInterface group. +// Don't use this type directly, use NewSecurityPoliciesInterfaceClient() instead. +type SecurityPoliciesInterfaceClient struct { + internal *arm.Client + subscriptionID string +} + +// NewSecurityPoliciesInterfaceClient creates a new instance of SecurityPoliciesInterfaceClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSecurityPoliciesInterfaceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecurityPoliciesInterfaceClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SecurityPoliciesInterfaceClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a SecurityPolicy +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - securityPolicyName - SecurityPolicy +// - resource - Resource create parameters. +// - options - SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.BeginCreateOrUpdate +// method. +func (client *SecurityPoliciesInterfaceClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, resource SecurityPolicy, options *SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions) (*runtime.Poller[SecurityPoliciesInterfaceClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, trafficControllerName, securityPolicyName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecurityPoliciesInterfaceClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SecurityPoliciesInterfaceClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a SecurityPolicy +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +func (client *SecurityPoliciesInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, resource SecurityPolicy, options *SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "SecurityPoliciesInterfaceClient.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, trafficControllerName, securityPolicyName, resource, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SecurityPoliciesInterfaceClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, resource SecurityPolicy, options *SecurityPoliciesInterfaceClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicy/{securityPolicyName}" + 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 trafficControllerName == "" { + return nil, errors.New("parameter trafficControllerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) + if securityPolicyName == "" { + return nil, errors.New("parameter securityPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{securityPolicyName}", url.PathEscape(securityPolicyName)) + 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", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a SecurityPolicy +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - securityPolicyName - SecurityPolicy +// - options - SecurityPoliciesInterfaceClientBeginDeleteOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.BeginDelete +// method. +func (client *SecurityPoliciesInterfaceClient) BeginDelete(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *SecurityPoliciesInterfaceClientBeginDeleteOptions) (*runtime.Poller[SecurityPoliciesInterfaceClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, trafficControllerName, securityPolicyName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecurityPoliciesInterfaceClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SecurityPoliciesInterfaceClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a SecurityPolicy +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +func (client *SecurityPoliciesInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *SecurityPoliciesInterfaceClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "SecurityPoliciesInterfaceClient.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, trafficControllerName, securityPolicyName, 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 *SecurityPoliciesInterfaceClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *SecurityPoliciesInterfaceClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicy/{securityPolicyName}" + 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 trafficControllerName == "" { + return nil, errors.New("parameter trafficControllerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) + if securityPolicyName == "" { + return nil, errors.New("parameter securityPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{securityPolicyName}", url.PathEscape(securityPolicyName)) + 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", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a SecurityPolicy +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - securityPolicyName - SecurityPolicy +// - options - SecurityPoliciesInterfaceClientGetOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.Get +// method. +func (client *SecurityPoliciesInterfaceClient) Get(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *SecurityPoliciesInterfaceClientGetOptions) (SecurityPoliciesInterfaceClientGetResponse, error) { + var err error + const operationName = "SecurityPoliciesInterfaceClient.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, trafficControllerName, securityPolicyName, options) + if err != nil { + return SecurityPoliciesInterfaceClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SecurityPoliciesInterfaceClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SecurityPoliciesInterfaceClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SecurityPoliciesInterfaceClient) getCreateRequest(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, options *SecurityPoliciesInterfaceClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicy/{securityPolicyName}" + 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 trafficControllerName == "" { + return nil, errors.New("parameter trafficControllerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) + if securityPolicyName == "" { + return nil, errors.New("parameter securityPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{securityPolicyName}", url.PathEscape(securityPolicyName)) + 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-05-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 *SecurityPoliciesInterfaceClient) getHandleResponse(resp *http.Response) (SecurityPoliciesInterfaceClientGetResponse, error) { + result := SecurityPoliciesInterfaceClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SecurityPolicy); err != nil { + return SecurityPoliciesInterfaceClientGetResponse{}, err + } + return result, nil +} + +// NewListByTrafficControllerPager - List SecurityPolicy resources by TrafficController +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - options - SecurityPoliciesInterfaceClientListByTrafficControllerOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager +// method. +func (client *SecurityPoliciesInterfaceClient) NewListByTrafficControllerPager(resourceGroupName string, trafficControllerName string, options *SecurityPoliciesInterfaceClientListByTrafficControllerOptions) *runtime.Pager[SecurityPoliciesInterfaceClientListByTrafficControllerResponse] { + return runtime.NewPager(runtime.PagingHandler[SecurityPoliciesInterfaceClientListByTrafficControllerResponse]{ + More: func(page SecurityPoliciesInterfaceClientListByTrafficControllerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SecurityPoliciesInterfaceClientListByTrafficControllerResponse) (SecurityPoliciesInterfaceClientListByTrafficControllerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SecurityPoliciesInterfaceClient.NewListByTrafficControllerPager") + 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.listByTrafficControllerCreateRequest(ctx, resourceGroupName, trafficControllerName, options) + }, nil) + if err != nil { + return SecurityPoliciesInterfaceClientListByTrafficControllerResponse{}, err + } + return client.listByTrafficControllerHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByTrafficControllerCreateRequest creates the ListByTrafficController request. +func (client *SecurityPoliciesInterfaceClient) listByTrafficControllerCreateRequest(ctx context.Context, resourceGroupName string, trafficControllerName string, options *SecurityPoliciesInterfaceClientListByTrafficControllerOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicy" + 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 trafficControllerName == "" { + return nil, errors.New("parameter trafficControllerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByTrafficControllerHandleResponse handles the ListByTrafficController response. +func (client *SecurityPoliciesInterfaceClient) listByTrafficControllerHandleResponse(resp *http.Response) (SecurityPoliciesInterfaceClientListByTrafficControllerResponse, error) { + result := SecurityPoliciesInterfaceClientListByTrafficControllerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SecurityPolicyListResult); err != nil { + return SecurityPoliciesInterfaceClientListByTrafficControllerResponse{}, err + } + return result, nil +} + +// Update - Update a SecurityPolicy +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - securityPolicyName - SecurityPolicy +// - properties - The resource properties to be updated. +// - options - SecurityPoliciesInterfaceClientUpdateOptions contains the optional parameters for the SecurityPoliciesInterfaceClient.Update +// method. +func (client *SecurityPoliciesInterfaceClient) Update(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, properties SecurityPolicyUpdate, options *SecurityPoliciesInterfaceClientUpdateOptions) (SecurityPoliciesInterfaceClientUpdateResponse, error) { + var err error + const operationName = "SecurityPoliciesInterfaceClient.Update" + 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, trafficControllerName, securityPolicyName, properties, options) + if err != nil { + return SecurityPoliciesInterfaceClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SecurityPoliciesInterfaceClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SecurityPoliciesInterfaceClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *SecurityPoliciesInterfaceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, trafficControllerName string, securityPolicyName string, properties SecurityPolicyUpdate, options *SecurityPoliciesInterfaceClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicy/{securityPolicyName}" + 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 trafficControllerName == "" { + return nil, errors.New("parameter trafficControllerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) + if securityPolicyName == "" { + return nil, errors.New("parameter securityPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{securityPolicyName}", url.PathEscape(securityPolicyName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *SecurityPoliciesInterfaceClient) updateHandleResponse(resp *http.Response) (SecurityPoliciesInterfaceClientUpdateResponse, error) { + result := SecurityPoliciesInterfaceClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SecurityPolicy); err != nil { + return SecurityPoliciesInterfaceClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go index 8ad85197d842..e2b025f5d16c 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // 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+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + 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 @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + 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 { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + 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)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { 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 @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go index be066259f3b3..7a6f8a7978ef 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go @@ -46,7 +46,7 @@ func NewTrafficControllerInterfaceClient(subscriptionID string, credential azcor // BeginCreateOrUpdate - Create a TrafficController // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - resource - Resource create parameters. @@ -73,7 +73,7 @@ func (client *TrafficControllerInterfaceClient) BeginCreateOrUpdate(ctx context. // CreateOrUpdate - Create a TrafficController // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview func (client *TrafficControllerInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, resource TrafficController, options *TrafficControllerInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "TrafficControllerInterfaceClient.BeginCreateOrUpdate" @@ -115,7 +115,7 @@ func (client *TrafficControllerInterfaceClient) createOrUpdateCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, resource); err != nil { @@ -127,7 +127,7 @@ func (client *TrafficControllerInterfaceClient) createOrUpdateCreateRequest(ctx // BeginDelete - Delete a TrafficController // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - options - TrafficControllerInterfaceClientBeginDeleteOptions contains the optional parameters for the TrafficControllerInterfaceClient.BeginDelete @@ -153,7 +153,7 @@ func (client *TrafficControllerInterfaceClient) BeginDelete(ctx context.Context, // Delete - Delete a TrafficController // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview func (client *TrafficControllerInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, options *TrafficControllerInterfaceClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "TrafficControllerInterfaceClient.BeginDelete" @@ -168,7 +168,7 @@ func (client *TrafficControllerInterfaceClient) deleteOperation(ctx context.Cont 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 } @@ -195,7 +195,7 @@ func (client *TrafficControllerInterfaceClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -204,7 +204,7 @@ func (client *TrafficControllerInterfaceClient) deleteCreateRequest(ctx context. // Get - Get a TrafficController // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - options - TrafficControllerInterfaceClientGetOptions contains the optional parameters for the TrafficControllerInterfaceClient.Get @@ -251,7 +251,7 @@ func (client *TrafficControllerInterfaceClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -268,7 +268,7 @@ func (client *TrafficControllerInterfaceClient) getHandleResponse(resp *http.Res // NewListByResourceGroupPager - List TrafficController resources by resource group // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - TrafficControllerInterfaceClientListByResourceGroupOptions contains the optional parameters for the TrafficControllerInterfaceClient.NewListByResourceGroupPager // method. @@ -311,7 +311,7 @@ func (client *TrafficControllerInterfaceClient) listByResourceGroupCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -328,7 +328,7 @@ func (client *TrafficControllerInterfaceClient) listByResourceGroupHandleRespons // NewListBySubscriptionPager - List TrafficController resources by subscription ID // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - options - TrafficControllerInterfaceClientListBySubscriptionOptions contains the optional parameters for the TrafficControllerInterfaceClient.NewListBySubscriptionPager // method. func (client *TrafficControllerInterfaceClient) NewListBySubscriptionPager(options *TrafficControllerInterfaceClientListBySubscriptionOptions) *runtime.Pager[TrafficControllerInterfaceClientListBySubscriptionResponse] { @@ -366,7 +366,7 @@ func (client *TrafficControllerInterfaceClient) listBySubscriptionCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -384,7 +384,7 @@ func (client *TrafficControllerInterfaceClient) listBySubscriptionHandleResponse // Update - Update a TrafficController // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-11-01 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - trafficControllerName - traffic controller name for path // - properties - The resource properties to be updated. @@ -432,7 +432,7 @@ func (client *TrafficControllerInterfaceClient) updateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-11-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, properties); err != nil { diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go deleted file mode 100644 index 3d753cf55300..000000000000 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go +++ /dev/null @@ -1,279 +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. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armservicenetworking_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllersGetList.json -func ExampleTrafficControllerInterfaceClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTrafficControllerInterfaceClient().NewListBySubscriptionPager(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.TrafficControllerListResult = armservicenetworking.TrafficControllerListResult{ - // Value: []*armservicenetworking.TrafficController{ - // { - // Name: to.Ptr("tc1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1"), - // Location: to.Ptr("NorthCentralUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // Properties: &armservicenetworking.TrafficControllerProperties{ - // Associations: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/association/as1"), - // }}, - // ConfigurationEndpoints: []*string{ - // to.Ptr("abc.trafficcontroller.azure.net")}, - // Frontends: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // }}, - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllersGet.json -func ExampleTrafficControllerInterfaceClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTrafficControllerInterfaceClient().NewListByResourceGroupPager("rg1", 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.TrafficControllerListResult = armservicenetworking.TrafficControllerListResult{ - // Value: []*armservicenetworking.TrafficController{ - // { - // Name: to.Ptr("tc1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1"), - // Location: to.Ptr("NorthCentralUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // Properties: &armservicenetworking.TrafficControllerProperties{ - // Associations: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/association/as1"), - // }}, - // ConfigurationEndpoints: []*string{ - // to.Ptr("abc.trafficcontroller.azure.net")}, - // Frontends: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // }}, - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerGet.json -func ExampleTrafficControllerInterfaceClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTrafficControllerInterfaceClient().Get(ctx, "rg1", "tc1", 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.TrafficController = armservicenetworking.TrafficController{ - // Name: to.Ptr("tc1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1"), - // Location: to.Ptr("NorthCentralUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // Properties: &armservicenetworking.TrafficControllerProperties{ - // Associations: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/association/as1"), - // }}, - // ConfigurationEndpoints: []*string{ - // to.Ptr("abc.trafficcontroller.azure.net")}, - // Frontends: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // }}, - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerPut.json -func ExampleTrafficControllerInterfaceClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTrafficControllerInterfaceClient().BeginCreateOrUpdate(ctx, "rg1", "tc1", armservicenetworking.TrafficController{ - Location: to.Ptr("NorthCentralUS"), - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, 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.TrafficController = armservicenetworking.TrafficController{ - // Name: to.Ptr("tc1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1"), - // Location: to.Ptr("NorthCentralUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // Properties: &armservicenetworking.TrafficControllerProperties{ - // Associations: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/association/as1"), - // }}, - // ConfigurationEndpoints: []*string{ - // to.Ptr("abc.trafficcontroller.azure.net")}, - // Frontends: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // }}, - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerPatch.json -func ExampleTrafficControllerInterfaceClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTrafficControllerInterfaceClient().Update(ctx, "rg1", "tc1", armservicenetworking.TrafficControllerUpdate{ - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, 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.TrafficController = armservicenetworking.TrafficController{ - // Name: to.Ptr("tc1"), - // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1"), - // Location: to.Ptr("NorthCentralUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // Properties: &armservicenetworking.TrafficControllerProperties{ - // Associations: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/association/as1"), - // }}, - // ConfigurationEndpoints: []*string{ - // to.Ptr("abc.trafficcontroller.azure.net")}, - // Frontends: []*armservicenetworking.ResourceID{ - // { - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficControllers/tc1/frontends/fe1"), - // }}, - // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerDelete.json -func ExampleTrafficControllerInterfaceClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTrafficControllerInterfaceClient().BeginDelete(ctx, "rg1", "tc1", 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) - } -}