From 4659c29bb3fffad2ae1cbdd28fdeeb2001a96a3b Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 13 Dec 2024 01:10:58 -0800 Subject: [PATCH] [Release] sdk/resourcemanager/cognitiveservices/armcognitiveservices/1.7.0 generation from spec commit: 069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5 (#23825) Co-authored-by: ReleaseHelper --- .../armcognitiveservices/CHANGELOG.md | 122 + .../armcognitiveservices/accounts_client.go | 50 +- .../accounts_client_example_test.go | 24 +- .../armcognitiveservices/autorest.md | 8 +- .../armcognitiveservices/client_factory.go | 152 +- .../commitmentplans_client.go | 68 +- .../commitmentplans_client_example_test.go | 28 +- .../commitmenttiers_client.go | 4 +- .../commitmenttiers_client_example_test.go | 2 +- .../armcognitiveservices/constants.go | 170 +- .../defenderforaisettings_client.go | 327 +++ ...fenderforaisettings_client_example_test.go | 183 ++ .../deletedaccounts_client.go | 14 +- .../deletedaccounts_client_example_test.go | 6 +- .../deployments_client.go | 175 +- .../deployments_client_example_test.go | 114 +- .../encryptionscopes_client.go | 333 +++ .../encryptionscopes_client_example_test.go | 194 ++ .../fake/defenderforaisettings_server.go | 250 ++ .../fake/deployments_server.go | 113 + .../fake/encryptionscopes_server.go | 259 +++ .../locationbasedmodelcapacities_server.go | 121 + .../fake/management_server.go | 35 + .../fake/modelcapacities_server.go | 117 + ...ksecurityperimeterconfigurations_server.go | 212 ++ .../fake/raiblocklistitems_server.go | 369 +++ .../fake/raiblocklists_server.go | 259 +++ .../fake/raicontentfilters_server.go | 148 ++ .../fake/raipolicies_server.go | 259 +++ .../fake/server_factory.go | 113 +- .../armcognitiveservices/fake/time_rfc3339.go | 42 +- .../locationbasedmodelcapacities_client.go | 110 + ...asedmodelcapacities_client_example_test.go | 62 + .../armcognitiveservices/management_client.go | 67 +- .../management_client_example_test.go | 58 +- .../modelcapacities_client.go | 105 + .../modelcapacities_client_example_test.go | 62 + .../armcognitiveservices/models.go | 647 +++++- .../armcognitiveservices/models_client.go | 4 +- .../models_client_example_test.go | 2 +- .../armcognitiveservices/models_serde.go | 2009 +++++++++++++++-- ...ksecurityperimeterconfigurations_client.go | 261 +++ ...meterconfigurations_client_example_test.go | 183 ++ .../armcognitiveservices/operations_client.go | 4 +- .../operations_client_example_test.go | 2 +- .../armcognitiveservices/options.go | 177 ++ .../privateendpointconnections_client.go | 20 +- ...endpointconnections_client_example_test.go | 8 +- .../privatelinkresources_client.go | 4 +- ...rivatelinkresources_client_example_test.go | 2 +- .../raiblocklistitems_client.go | 492 ++++ .../raiblocklistitems_client_example_test.go | 206 ++ .../raiblocklists_client.go | 333 +++ .../raiblocklists_client_example_test.go | 133 ++ .../raicontentfilters_client.go | 168 ++ .../raicontentfilters_client_example_test.go | 161 ++ .../raipolicies_client.go | 332 +++ .../raipolicies_client_example_test.go | 461 ++++ .../resourceskus_client.go | 4 +- .../resourceskus_client_example_test.go | 2 +- .../{response_types.go => responses.go} | 187 ++ .../armcognitiveservices/time_rfc3339.go | 42 +- .../armcognitiveservices/usages_client.go | 4 +- .../usages_client_example_test.go | 2 +- 64 files changed, 10216 insertions(+), 369 deletions(-) create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/defenderforaisettings_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/encryptionscopes_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/locationbasedmodelcapacities_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/modelcapacities_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/networksecurityperimeterconfigurations_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklistitems_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklists_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raicontentfilters_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raipolicies_server.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client_example_test.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client.go create mode 100644 sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client_example_test.go rename sdk/resourcemanager/cognitiveservices/armcognitiveservices/{response_types.go => responses.go} (59%) diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md index a0697812223f..16efa8052f94 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/CHANGELOG.md @@ -1,5 +1,127 @@ # Release History +## 1.7.0 (2024-12-27) +### Features Added + +- New value `ModelLifecycleStatusDeprecated`, `ModelLifecycleStatusDeprecating`, `ModelLifecycleStatusStable` added to enum type `ModelLifecycleStatus` +- New enum type `ByPassSelection` with values `ByPassSelectionAzureServices`, `ByPassSelectionNone` +- New enum type `ContentLevel` with values `ContentLevelHigh`, `ContentLevelLow`, `ContentLevelMedium` +- New enum type `DefenderForAISettingState` with values `DefenderForAISettingStateDisabled`, `DefenderForAISettingStateEnabled` +- New enum type `EncryptionScopeProvisioningState` with values `EncryptionScopeProvisioningStateAccepted`, `EncryptionScopeProvisioningStateCanceled`, `EncryptionScopeProvisioningStateCreating`, `EncryptionScopeProvisioningStateDeleting`, `EncryptionScopeProvisioningStateFailed`, `EncryptionScopeProvisioningStateMoving`, `EncryptionScopeProvisioningStateSucceeded` +- New enum type `EncryptionScopeState` with values `EncryptionScopeStateDisabled`, `EncryptionScopeStateEnabled` +- New enum type `NspAccessRuleDirection` with values `NspAccessRuleDirectionInbound`, `NspAccessRuleDirectionOutbound` +- New enum type `RaiPolicyContentSource` with values `RaiPolicyContentSourceCompletion`, `RaiPolicyContentSourcePrompt` +- New enum type `RaiPolicyMode` with values `RaiPolicyModeAsynchronousFilter`, `RaiPolicyModeBlocking`, `RaiPolicyModeDefault`, `RaiPolicyModeDeferred` +- New enum type `RaiPolicyType` with values `RaiPolicyTypeSystemManaged`, `RaiPolicyTypeUserManaged` +- New function `*ClientFactory.NewDefenderForAISettingsClient() *DefenderForAISettingsClient` +- New function `*ClientFactory.NewEncryptionScopesClient() *EncryptionScopesClient` +- New function `*ClientFactory.NewLocationBasedModelCapacitiesClient() *LocationBasedModelCapacitiesClient` +- New function `*ClientFactory.NewModelCapacitiesClient() *ModelCapacitiesClient` +- New function `*ClientFactory.NewNetworkSecurityPerimeterConfigurationsClient() *NetworkSecurityPerimeterConfigurationsClient` +- New function `*ClientFactory.NewRaiBlocklistItemsClient() *RaiBlocklistItemsClient` +- New function `*ClientFactory.NewRaiBlocklistsClient() *RaiBlocklistsClient` +- New function `*ClientFactory.NewRaiContentFiltersClient() *RaiContentFiltersClient` +- New function `*ClientFactory.NewRaiPoliciesClient() *RaiPoliciesClient` +- New function `NewDefenderForAISettingsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DefenderForAISettingsClient, error)` +- New function `*DefenderForAISettingsClient.CreateOrUpdate(context.Context, string, string, string, DefenderForAISetting, *DefenderForAISettingsClientCreateOrUpdateOptions) (DefenderForAISettingsClientCreateOrUpdateResponse, error)` +- New function `*DefenderForAISettingsClient.Get(context.Context, string, string, string, *DefenderForAISettingsClientGetOptions) (DefenderForAISettingsClientGetResponse, error)` +- New function `*DefenderForAISettingsClient.NewListPager(string, string, *DefenderForAISettingsClientListOptions) *runtime.Pager[DefenderForAISettingsClientListResponse]` +- New function `*DefenderForAISettingsClient.Update(context.Context, string, string, string, DefenderForAISetting, *DefenderForAISettingsClientUpdateOptions) (DefenderForAISettingsClientUpdateResponse, error)` +- New function `*DeploymentsClient.NewListSKUsPager(string, string, string, *DeploymentsClientListSKUsOptions) *runtime.Pager[DeploymentsClientListSKUsResponse]` +- New function `*DeploymentsClient.BeginUpdate(context.Context, string, string, string, PatchResourceTagsAndSKU, *DeploymentsClientBeginUpdateOptions) (*runtime.Poller[DeploymentsClientUpdateResponse], error)` +- New function `NewEncryptionScopesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*EncryptionScopesClient, error)` +- New function `*EncryptionScopesClient.CreateOrUpdate(context.Context, string, string, string, EncryptionScope, *EncryptionScopesClientCreateOrUpdateOptions) (EncryptionScopesClientCreateOrUpdateResponse, error)` +- New function `*EncryptionScopesClient.BeginDelete(context.Context, string, string, string, *EncryptionScopesClientBeginDeleteOptions) (*runtime.Poller[EncryptionScopesClientDeleteResponse], error)` +- New function `*EncryptionScopesClient.Get(context.Context, string, string, string, *EncryptionScopesClientGetOptions) (EncryptionScopesClientGetResponse, error)` +- New function `*EncryptionScopesClient.NewListPager(string, string, *EncryptionScopesClientListOptions) *runtime.Pager[EncryptionScopesClientListResponse]` +- New function `NewLocationBasedModelCapacitiesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*LocationBasedModelCapacitiesClient, error)` +- New function `*LocationBasedModelCapacitiesClient.NewListPager(string, string, string, string, *LocationBasedModelCapacitiesClientListOptions) *runtime.Pager[LocationBasedModelCapacitiesClientListResponse]` +- New function `*ManagementClient.CalculateModelCapacity(context.Context, CalculateModelCapacityParameter, *ManagementClientCalculateModelCapacityOptions) (ManagementClientCalculateModelCapacityResponse, error)` +- New function `NewModelCapacitiesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ModelCapacitiesClient, error)` +- New function `*ModelCapacitiesClient.NewListPager(string, string, string, *ModelCapacitiesClientListOptions) *runtime.Pager[ModelCapacitiesClientListResponse]` +- New function `NewRaiBlocklistItemsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*RaiBlocklistItemsClient, error)` +- New function `*RaiBlocklistItemsClient.BatchAdd(context.Context, string, string, string, []*RaiBlocklistItemBulkRequest, *RaiBlocklistItemsClientBatchAddOptions) (RaiBlocklistItemsClientBatchAddResponse, error)` +- New function `*RaiBlocklistItemsClient.BatchDelete(context.Context, string, string, string, any, *RaiBlocklistItemsClientBatchDeleteOptions) (RaiBlocklistItemsClientBatchDeleteResponse, error)` +- New function `*RaiBlocklistItemsClient.CreateOrUpdate(context.Context, string, string, string, string, RaiBlocklistItem, *RaiBlocklistItemsClientCreateOrUpdateOptions) (RaiBlocklistItemsClientCreateOrUpdateResponse, error)` +- New function `*RaiBlocklistItemsClient.BeginDelete(context.Context, string, string, string, string, *RaiBlocklistItemsClientBeginDeleteOptions) (*runtime.Poller[RaiBlocklistItemsClientDeleteResponse], error)` +- New function `*RaiBlocklistItemsClient.Get(context.Context, string, string, string, string, *RaiBlocklistItemsClientGetOptions) (RaiBlocklistItemsClientGetResponse, error)` +- New function `*RaiBlocklistItemsClient.NewListPager(string, string, string, *RaiBlocklistItemsClientListOptions) *runtime.Pager[RaiBlocklistItemsClientListResponse]` +- New function `NewRaiBlocklistsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*RaiBlocklistsClient, error)` +- New function `*RaiBlocklistsClient.CreateOrUpdate(context.Context, string, string, string, RaiBlocklist, *RaiBlocklistsClientCreateOrUpdateOptions) (RaiBlocklistsClientCreateOrUpdateResponse, error)` +- New function `*RaiBlocklistsClient.BeginDelete(context.Context, string, string, string, *RaiBlocklistsClientBeginDeleteOptions) (*runtime.Poller[RaiBlocklistsClientDeleteResponse], error)` +- New function `*RaiBlocklistsClient.Get(context.Context, string, string, string, *RaiBlocklistsClientGetOptions) (RaiBlocklistsClientGetResponse, error)` +- New function `*RaiBlocklistsClient.NewListPager(string, string, *RaiBlocklistsClientListOptions) *runtime.Pager[RaiBlocklistsClientListResponse]` +- New function `NewRaiContentFiltersClient(string, azcore.TokenCredential, *arm.ClientOptions) (*RaiContentFiltersClient, error)` +- New function `*RaiContentFiltersClient.Get(context.Context, string, string, *RaiContentFiltersClientGetOptions) (RaiContentFiltersClientGetResponse, error)` +- New function `*RaiContentFiltersClient.NewListPager(string, *RaiContentFiltersClientListOptions) *runtime.Pager[RaiContentFiltersClientListResponse]` +- New function `NewRaiPoliciesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*RaiPoliciesClient, error)` +- New function `*RaiPoliciesClient.CreateOrUpdate(context.Context, string, string, string, RaiPolicy, *RaiPoliciesClientCreateOrUpdateOptions) (RaiPoliciesClientCreateOrUpdateResponse, error)` +- New function `*RaiPoliciesClient.BeginDelete(context.Context, string, string, string, *RaiPoliciesClientBeginDeleteOptions) (*runtime.Poller[RaiPoliciesClientDeleteResponse], error)` +- New function `*RaiPoliciesClient.Get(context.Context, string, string, string, *RaiPoliciesClientGetOptions) (RaiPoliciesClientGetResponse, error)` +- New function `*RaiPoliciesClient.NewListPager(string, string, *RaiPoliciesClientListOptions) *runtime.Pager[RaiPoliciesClientListResponse]` +- New function `NewNetworkSecurityPerimeterConfigurationsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*NetworkSecurityPerimeterConfigurationsClient, error)` +- New function `*NetworkSecurityPerimeterConfigurationsClient.Get(context.Context, string, string, string, *NetworkSecurityPerimeterConfigurationsClientGetOptions) (NetworkSecurityPerimeterConfigurationsClientGetResponse, error)` +- New function `*NetworkSecurityPerimeterConfigurationsClient.NewListPager(string, string, *NetworkSecurityPerimeterConfigurationsClientListOptions) *runtime.Pager[NetworkSecurityPerimeterConfigurationsClientListResponse]` +- New function `*NetworkSecurityPerimeterConfigurationsClient.BeginReconcile(context.Context, string, string, string, *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*runtime.Poller[NetworkSecurityPerimeterConfigurationsClientReconcileResponse], error)` +- New struct `BillingMeterInfo` +- New struct `CalculateModelCapacityParameter` +- New struct `CalculateModelCapacityResult` +- New struct `CalculateModelCapacityResultEstimatedCapacity` +- New struct `CustomBlocklistConfig` +- New struct `DefenderForAISetting` +- New struct `DefenderForAISettingProperties` +- New struct `DefenderForAISettingResult` +- New struct `DeploymentCapacitySettings` +- New struct `DeploymentSKUListResult` +- New struct `EncryptionScope` +- New struct `EncryptionScopeListResult` +- New struct `EncryptionScopeProperties` +- New struct `ModelCapacityCalculatorWorkload` +- New struct `ModelCapacityCalculatorWorkloadRequestParam` +- New struct `ModelCapacityListResult` +- New struct `ModelCapacityListResultValueItem` +- New struct `ModelSKUCapacityProperties` +- New struct `NetworkSecurityPerimeter` +- New struct `NetworkSecurityPerimeterAccessRule` +- New struct `NetworkSecurityPerimeterAccessRuleProperties` +- New struct `NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem` +- New struct `NetworkSecurityPerimeterConfiguration` +- New struct `NetworkSecurityPerimeterConfigurationAssociationInfo` +- New struct `NetworkSecurityPerimeterConfigurationList` +- New struct `NetworkSecurityPerimeterConfigurationProperties` +- New struct `NetworkSecurityPerimeterProfileInfo` +- New struct `ProvisioningIssue` +- New struct `ProvisioningIssueProperties` +- New struct `RaiBlockListItemsResult` +- New struct `RaiBlockListResult` +- New struct `RaiBlocklist` +- New struct `RaiBlocklistConfig` +- New struct `RaiBlocklistItem` +- New struct `RaiBlocklistItemBulkRequest` +- New struct `RaiBlocklistItemProperties` +- New struct `RaiBlocklistProperties` +- New struct `RaiContentFilter` +- New struct `RaiContentFilterListResult` +- New struct `RaiContentFilterProperties` +- New struct `RaiMonitorConfig` +- New struct `RaiPolicy` +- New struct `RaiPolicyContentFilter` +- New struct `RaiPolicyListResult` +- New struct `RaiPolicyProperties` +- New struct `SKUResource` +- New struct `UserOwnedAmlWorkspace` +- New field `Publisher`, `SourceAccount` in struct `AccountModel` +- New field `AmlWorkspace`, `RaiMonitorConfig` in struct `AccountProperties` +- New field `AllowedValues` in struct `CapacityConfig` +- New field `Tags` in struct `CommitmentPlanAccountAssociation` +- New field `Tags` in struct `Deployment` +- New field `Publisher`, `SourceAccount` in struct `DeploymentModel` +- New field `CapacitySettings`, `CurrentCapacity`, `DynamicThrottlingEnabled`, `ParentDeploymentName` in struct `DeploymentProperties` +- New field `Description` in struct `Model` +- New field `Cost` in struct `ModelSKU` +- New field `Bypass` in struct `NetworkRuleSet` + + ## 1.6.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go index bd3916f2abf9..173f3f8fb4d8 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client.go @@ -47,7 +47,7 @@ func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, // developer to access intelligent APIs. It's also the resource type for billing. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - account - The parameters to provide for the created account. @@ -73,7 +73,7 @@ func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName // to access intelligent APIs. It's also the resource type for billing. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *AccountsClient) create(ctx context.Context, resourceGroupName string, accountName string, account Account, options *AccountsClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "AccountsClient.BeginCreate" @@ -115,7 +115,7 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, account); err != nil { @@ -127,7 +127,7 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Deletes a Cognitive Services account from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - AccountsClientBeginDeleteOptions contains the optional parameters for the AccountsClient.BeginDelete method. @@ -151,7 +151,7 @@ func (client *AccountsClient) BeginDelete(ctx context.Context, resourceGroupName // Delete - Deletes a Cognitive Services account from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *AccountsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "AccountsClient.BeginDelete" @@ -193,7 +193,7 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -202,7 +202,7 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Returns a Cognitive Services account specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. @@ -248,7 +248,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -265,7 +265,7 @@ func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsCl // NewListPager - Returns all the resources of a particular type belonging to a subscription. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - options - AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) *runtime.Pager[AccountsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListResponse]{ @@ -302,7 +302,7 @@ func (client *AccountsClient) listCreateRequest(ctx context.Context, options *Ac return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -319,7 +319,7 @@ func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsC // NewListByResourceGroupPager - Returns all the resources of a particular type belonging to a resource group // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.NewListByResourceGroupPager // method. @@ -362,7 +362,7 @@ func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -380,7 +380,7 @@ func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Respo // ListKeys - Lists the account keys for the specified Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.ListKeys method. @@ -426,7 +426,7 @@ func (client *AccountsClient) listKeysCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -443,7 +443,7 @@ func (client *AccountsClient) listKeysHandleResponse(resp *http.Response) (Accou // NewListModelsPager - List available Models for the requested Cognitive Services account // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - AccountsClientListModelsOptions contains the optional parameters for the AccountsClient.NewListModelsPager method. @@ -490,7 +490,7 @@ func (client *AccountsClient) listModelsCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -508,7 +508,7 @@ func (client *AccountsClient) listModelsHandleResponse(resp *http.Response) (Acc // ListSKUs - List available SKUs for the requested Cognitive Services account // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - AccountsClientListSKUsOptions contains the optional parameters for the AccountsClient.ListSKUs method. @@ -554,7 +554,7 @@ func (client *AccountsClient) listSKUsCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -572,7 +572,7 @@ func (client *AccountsClient) listSKUsHandleResponse(resp *http.Response) (Accou // ListUsages - Get usages for the requested Cognitive Services account // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - AccountsClientListUsagesOptions contains the optional parameters for the AccountsClient.ListUsages method. @@ -618,10 +618,10 @@ func (client *AccountsClient) listUsagesCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -639,7 +639,7 @@ func (client *AccountsClient) listUsagesHandleResponse(resp *http.Response) (Acc // RegenerateKey - Regenerates the specified account key for the specified Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - parameters - regenerate key parameters. @@ -686,7 +686,7 @@ func (client *AccountsClient) regenerateKeyCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -707,7 +707,7 @@ func (client *AccountsClient) regenerateKeyHandleResponse(resp *http.Response) ( // BeginUpdate - Updates a Cognitive Services account // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - account - The parameters to provide for the created account. @@ -732,7 +732,7 @@ func (client *AccountsClient) BeginUpdate(ctx context.Context, resourceGroupName // Update - Updates a Cognitive Services account // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *AccountsClient) update(ctx context.Context, resourceGroupName string, accountName string, account Account, options *AccountsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "AccountsClient.BeginUpdate" @@ -774,7 +774,7 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, account); err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go index 9c804a4f8b85..8d06db6f7ed3 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/accounts_client_example_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateAccount.json func ExampleAccountsClient_BeginCreate_createAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -97,7 +97,7 @@ func ExampleAccountsClient_BeginCreate_createAccount() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateAccountMin.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateAccountMin.json func ExampleAccountsClient_BeginCreate_createAccountMin() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -151,7 +151,7 @@ func ExampleAccountsClient_BeginCreate_createAccountMin() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/UpdateAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateAccount.json func ExampleAccountsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -195,7 +195,7 @@ func ExampleAccountsClient_BeginUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteAccount.json func ExampleAccountsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -216,7 +216,7 @@ func ExampleAccountsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetAccount.json func ExampleAccountsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -255,7 +255,7 @@ func ExampleAccountsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListAccountsByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountsByResourceGroup.json func ExampleAccountsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -319,7 +319,7 @@ func ExampleAccountsClient_NewListByResourceGroupPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListAccountsBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountsBySubscription.json func ExampleAccountsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -410,7 +410,7 @@ func ExampleAccountsClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListKeys.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListKeys.json func ExampleAccountsClient_ListKeys() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -434,7 +434,7 @@ func ExampleAccountsClient_ListKeys() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/RegenerateKey.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/RegenerateKey.json func ExampleAccountsClient_RegenerateKey() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -460,7 +460,7 @@ func ExampleAccountsClient_RegenerateKey() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSkus.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSkus.json func ExampleAccountsClient_ListSKUs() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -497,7 +497,7 @@ func ExampleAccountsClient_ListSKUs() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetUsages.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetUsages.json func ExampleAccountsClient_ListUsages() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -532,7 +532,7 @@ func ExampleAccountsClient_ListUsages() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListAccountModels.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountModels.json func ExampleAccountsClient_NewListModelsPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md index 900c143ada3c..a08ac854ee45 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.6.0 -tag: package-2023-05 +module-version: 1.7.0 +tag: package-2024-10 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go index eda98b5e2e1d..c3644d9152ed 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/client_factory.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/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,84 +26,179 @@ 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 } // NewAccountsClient creates a new instance of AccountsClient. func (c *ClientFactory) NewAccountsClient() *AccountsClient { - subClient, _ := NewAccountsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AccountsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewCommitmentPlansClient creates a new instance of CommitmentPlansClient. func (c *ClientFactory) NewCommitmentPlansClient() *CommitmentPlansClient { - subClient, _ := NewCommitmentPlansClient(c.subscriptionID, c.credential, c.options) - return subClient + return &CommitmentPlansClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewCommitmentTiersClient creates a new instance of CommitmentTiersClient. func (c *ClientFactory) NewCommitmentTiersClient() *CommitmentTiersClient { - subClient, _ := NewCommitmentTiersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &CommitmentTiersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewDefenderForAISettingsClient creates a new instance of DefenderForAISettingsClient. +func (c *ClientFactory) NewDefenderForAISettingsClient() *DefenderForAISettingsClient { + return &DefenderForAISettingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDeletedAccountsClient creates a new instance of DeletedAccountsClient. func (c *ClientFactory) NewDeletedAccountsClient() *DeletedAccountsClient { - subClient, _ := NewDeletedAccountsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeletedAccountsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDeploymentsClient creates a new instance of DeploymentsClient. func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { - subClient, _ := NewDeploymentsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeploymentsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewEncryptionScopesClient creates a new instance of EncryptionScopesClient. +func (c *ClientFactory) NewEncryptionScopesClient() *EncryptionScopesClient { + return &EncryptionScopesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewLocationBasedModelCapacitiesClient creates a new instance of LocationBasedModelCapacitiesClient. +func (c *ClientFactory) NewLocationBasedModelCapacitiesClient() *LocationBasedModelCapacitiesClient { + return &LocationBasedModelCapacitiesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewManagementClient creates a new instance of ManagementClient. func (c *ClientFactory) NewManagementClient() *ManagementClient { - subClient, _ := NewManagementClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ManagementClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewModelCapacitiesClient creates a new instance of ModelCapacitiesClient. +func (c *ClientFactory) NewModelCapacitiesClient() *ModelCapacitiesClient { + return &ModelCapacitiesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewModelsClient creates a new instance of ModelsClient. func (c *ClientFactory) NewModelsClient() *ModelsClient { - subClient, _ := NewModelsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ModelsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewNetworkSecurityPerimeterConfigurationsClient creates a new instance of NetworkSecurityPerimeterConfigurationsClient. +func (c *ClientFactory) NewNetworkSecurityPerimeterConfigurationsClient() *NetworkSecurityPerimeterConfigurationsClient { + return &NetworkSecurityPerimeterConfigurationsClient{ + 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, + } } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { - subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateEndpointConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { - subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateLinkResourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRaiBlocklistItemsClient creates a new instance of RaiBlocklistItemsClient. +func (c *ClientFactory) NewRaiBlocklistItemsClient() *RaiBlocklistItemsClient { + return &RaiBlocklistItemsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRaiBlocklistsClient creates a new instance of RaiBlocklistsClient. +func (c *ClientFactory) NewRaiBlocklistsClient() *RaiBlocklistsClient { + return &RaiBlocklistsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRaiContentFiltersClient creates a new instance of RaiContentFiltersClient. +func (c *ClientFactory) NewRaiContentFiltersClient() *RaiContentFiltersClient { + return &RaiContentFiltersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRaiPoliciesClient creates a new instance of RaiPoliciesClient. +func (c *ClientFactory) NewRaiPoliciesClient() *RaiPoliciesClient { + return &RaiPoliciesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewResourceSKUsClient creates a new instance of ResourceSKUsClient. func (c *ClientFactory) NewResourceSKUsClient() *ResourceSKUsClient { - subClient, _ := NewResourceSKUsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ResourceSKUsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewUsagesClient creates a new instance of UsagesClient. func (c *ClientFactory) NewUsagesClient() *UsagesClient { - subClient, _ := NewUsagesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &UsagesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go index 8ec8b1b08da8..e3c1f3b2e0b5 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client.go @@ -46,7 +46,7 @@ func NewCommitmentPlansClient(subscriptionID string, credential azcore.TokenCred // CreateOrUpdate - Update the state of specified commitmentPlans associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account @@ -99,7 +99,7 @@ func (client *CommitmentPlansClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, commitmentPlan); err != nil { @@ -120,7 +120,7 @@ func (client *CommitmentPlansClient) createOrUpdateHandleResponse(resp *http.Res // BeginCreateOrUpdateAssociation - Create or update the association of the Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - commitmentPlanAssociationName - The name of the commitment plan association with the Cognitive Services Account @@ -148,7 +148,7 @@ func (client *CommitmentPlansClient) BeginCreateOrUpdateAssociation(ctx context. // CreateOrUpdateAssociation - Create or update the association of the Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *CommitmentPlansClient) createOrUpdateAssociation(ctx context.Context, resourceGroupName string, commitmentPlanName string, commitmentPlanAssociationName string, association CommitmentPlanAccountAssociation, options *CommitmentPlansClientBeginCreateOrUpdateAssociationOptions) (*http.Response, error) { var err error const operationName = "CommitmentPlansClient.BeginCreateOrUpdateAssociation" @@ -194,7 +194,7 @@ func (client *CommitmentPlansClient) createOrUpdateAssociationCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, association); err != nil { @@ -206,7 +206,7 @@ func (client *CommitmentPlansClient) createOrUpdateAssociationCreateRequest(ctx // BeginCreateOrUpdatePlan - Create Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - commitmentPlan - The parameters to provide for the created commitment plan. @@ -233,7 +233,7 @@ func (client *CommitmentPlansClient) BeginCreateOrUpdatePlan(ctx context.Context // CreateOrUpdatePlan - Create Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *CommitmentPlansClient) createOrUpdatePlan(ctx context.Context, resourceGroupName string, commitmentPlanName string, commitmentPlan CommitmentPlan, options *CommitmentPlansClientBeginCreateOrUpdatePlanOptions) (*http.Response, error) { var err error const operationName = "CommitmentPlansClient.BeginCreateOrUpdatePlan" @@ -275,7 +275,7 @@ func (client *CommitmentPlansClient) createOrUpdatePlanCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, commitmentPlan); err != nil { @@ -287,7 +287,7 @@ func (client *CommitmentPlansClient) createOrUpdatePlanCreateRequest(ctx context // BeginDelete - Deletes the specified commitmentPlan associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account @@ -313,7 +313,7 @@ func (client *CommitmentPlansClient) BeginDelete(ctx context.Context, resourceGr // Delete - Deletes the specified commitmentPlan associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *CommitmentPlansClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, commitmentPlanName string, options *CommitmentPlansClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "CommitmentPlansClient.BeginDelete" @@ -359,7 +359,7 @@ func (client *CommitmentPlansClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -368,7 +368,7 @@ func (client *CommitmentPlansClient) deleteCreateRequest(ctx context.Context, re // BeginDeleteAssociation - Deletes the association of the Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - commitmentPlanAssociationName - The name of the commitment plan association with the Cognitive Services Account @@ -395,7 +395,7 @@ func (client *CommitmentPlansClient) BeginDeleteAssociation(ctx context.Context, // DeleteAssociation - Deletes the association of the Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *CommitmentPlansClient) deleteAssociation(ctx context.Context, resourceGroupName string, commitmentPlanName string, commitmentPlanAssociationName string, options *CommitmentPlansClientBeginDeleteAssociationOptions) (*http.Response, error) { var err error const operationName = "CommitmentPlansClient.BeginDeleteAssociation" @@ -441,7 +441,7 @@ func (client *CommitmentPlansClient) deleteAssociationCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -450,7 +450,7 @@ func (client *CommitmentPlansClient) deleteAssociationCreateRequest(ctx context. // BeginDeletePlan - Deletes a Cognitive Services commitment plan from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - options - CommitmentPlansClientBeginDeletePlanOptions contains the optional parameters for the CommitmentPlansClient.BeginDeletePlan @@ -476,7 +476,7 @@ func (client *CommitmentPlansClient) BeginDeletePlan(ctx context.Context, resour // DeletePlan - Deletes a Cognitive Services commitment plan from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *CommitmentPlansClient) deletePlan(ctx context.Context, resourceGroupName string, commitmentPlanName string, options *CommitmentPlansClientBeginDeletePlanOptions) (*http.Response, error) { var err error const operationName = "CommitmentPlansClient.BeginDeletePlan" @@ -518,7 +518,7 @@ func (client *CommitmentPlansClient) deletePlanCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -527,7 +527,7 @@ func (client *CommitmentPlansClient) deletePlanCreateRequest(ctx context.Context // Get - Gets the specified commitmentPlans associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account @@ -578,7 +578,7 @@ func (client *CommitmentPlansClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -596,7 +596,7 @@ func (client *CommitmentPlansClient) getHandleResponse(resp *http.Response) (Com // GetAssociation - Gets the association of the Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - commitmentPlanAssociationName - The name of the commitment plan association with the Cognitive Services Account @@ -648,7 +648,7 @@ func (client *CommitmentPlansClient) getAssociationCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -666,7 +666,7 @@ func (client *CommitmentPlansClient) getAssociationHandleResponse(resp *http.Res // GetPlan - Returns a Cognitive Services commitment plan specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - options - CommitmentPlansClientGetPlanOptions contains the optional parameters for the CommitmentPlansClient.GetPlan method. @@ -712,7 +712,7 @@ func (client *CommitmentPlansClient) getPlanCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -729,7 +729,7 @@ func (client *CommitmentPlansClient) getPlanHandleResponse(resp *http.Response) // NewListPager - Gets the commitmentPlans associated with the Cognitive Services account. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - CommitmentPlansClientListOptions contains the optional parameters for the CommitmentPlansClient.NewListPager @@ -777,7 +777,7 @@ func (client *CommitmentPlansClient) listCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -794,7 +794,7 @@ func (client *CommitmentPlansClient) listHandleResponse(resp *http.Response) (Co // NewListAssociationsPager - Gets the associations of the Cognitive Services commitment plan. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - options - CommitmentPlansClientListAssociationsOptions contains the optional parameters for the CommitmentPlansClient.NewListAssociationsPager @@ -842,7 +842,7 @@ func (client *CommitmentPlansClient) listAssociationsCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -859,7 +859,7 @@ func (client *CommitmentPlansClient) listAssociationsHandleResponse(resp *http.R // NewListPlansByResourceGroupPager - Returns all the resources of a particular type belonging to a resource group // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - CommitmentPlansClientListPlansByResourceGroupOptions contains the optional parameters for the CommitmentPlansClient.NewListPlansByResourceGroupPager // method. @@ -902,7 +902,7 @@ func (client *CommitmentPlansClient) listPlansByResourceGroupCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -919,7 +919,7 @@ func (client *CommitmentPlansClient) listPlansByResourceGroupHandleResponse(resp // NewListPlansBySubscriptionPager - Returns all the resources of a particular type belonging to a subscription. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - options - CommitmentPlansClientListPlansBySubscriptionOptions contains the optional parameters for the CommitmentPlansClient.NewListPlansBySubscriptionPager // method. func (client *CommitmentPlansClient) NewListPlansBySubscriptionPager(options *CommitmentPlansClientListPlansBySubscriptionOptions) *runtime.Pager[CommitmentPlansClientListPlansBySubscriptionResponse] { @@ -957,7 +957,7 @@ func (client *CommitmentPlansClient) listPlansBySubscriptionCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -975,7 +975,7 @@ func (client *CommitmentPlansClient) listPlansBySubscriptionHandleResponse(resp // BeginUpdatePlan - Create Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - commitmentPlanName - The name of the commitmentPlan associated with the Cognitive Services Account // - commitmentPlan - The parameters to provide for the created commitment plan. @@ -1002,7 +1002,7 @@ func (client *CommitmentPlansClient) BeginUpdatePlan(ctx context.Context, resour // UpdatePlan - Create Cognitive Services commitment plan. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *CommitmentPlansClient) updatePlan(ctx context.Context, resourceGroupName string, commitmentPlanName string, commitmentPlan PatchResourceTagsAndSKU, options *CommitmentPlansClientBeginUpdatePlanOptions) (*http.Response, error) { var err error const operationName = "CommitmentPlansClient.BeginUpdatePlan" @@ -1044,7 +1044,7 @@ func (client *CommitmentPlansClient) updatePlanCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, commitmentPlan); err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go index 9121bbb326a7..4964d82ca8de 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmentplans_client_example_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListCommitmentPlans.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListCommitmentPlans.json func ExampleCommitmentPlansClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -59,7 +59,7 @@ func ExampleCommitmentPlansClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetCommitmentPlan.json func ExampleCommitmentPlansClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -92,7 +92,7 @@ func ExampleCommitmentPlansClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutCommitmentPlan.json func ExampleCommitmentPlansClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -134,7 +134,7 @@ func ExampleCommitmentPlansClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteCommitmentPlan.json func ExampleCommitmentPlansClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -155,7 +155,7 @@ func ExampleCommitmentPlansClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateSharedCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateSharedCommitmentPlan.json func ExampleCommitmentPlansClient_BeginCreateOrUpdatePlan() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -212,7 +212,7 @@ func ExampleCommitmentPlansClient_BeginCreateOrUpdatePlan() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/UpdateSharedCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateSharedCommitmentPlan.json func ExampleCommitmentPlansClient_BeginUpdatePlan() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -262,7 +262,7 @@ func ExampleCommitmentPlansClient_BeginUpdatePlan() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteSharedCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteSharedCommitmentPlan.json func ExampleCommitmentPlansClient_BeginDeletePlan() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -283,7 +283,7 @@ func ExampleCommitmentPlansClient_BeginDeletePlan() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlan.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlan.json func ExampleCommitmentPlansClient_GetPlan() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -322,7 +322,7 @@ func ExampleCommitmentPlansClient_GetPlan() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSharedCommitmentPlansByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlansByResourceGroup.json func ExampleCommitmentPlansClient_NewListPlansByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -369,7 +369,7 @@ func ExampleCommitmentPlansClient_NewListPlansByResourceGroupPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSharedCommitmentPlansBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlansBySubscription.json func ExampleCommitmentPlansClient_NewListPlansBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -416,7 +416,7 @@ func ExampleCommitmentPlansClient_NewListPlansBySubscriptionPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListSharedCommitmentPlanAssociations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlanAssociations.json func ExampleCommitmentPlansClient_NewListAssociationsPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -452,7 +452,7 @@ func ExampleCommitmentPlansClient_NewListAssociationsPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSharedCommitmentPlanAssociation.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlanAssociation.json func ExampleCommitmentPlansClient_GetAssociation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -480,7 +480,7 @@ func ExampleCommitmentPlansClient_GetAssociation() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CreateSharedCommitmentPlanAssociation.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateSharedCommitmentPlanAssociation.json func ExampleCommitmentPlansClient_BeginCreateOrUpdateAssociation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -516,7 +516,7 @@ func ExampleCommitmentPlansClient_BeginCreateOrUpdateAssociation() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteSharedCommitmentPlanAssociation.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteSharedCommitmentPlanAssociation.json func ExampleCommitmentPlansClient_BeginDeleteAssociation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go index 790015c03a5b..8d1078d9b168 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client.go @@ -45,7 +45,7 @@ func NewCommitmentTiersClient(subscriptionID string, credential azcore.TokenCred // NewListPager - List Commitment Tiers. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - location - Resource location. // - options - CommitmentTiersClientListOptions contains the optional parameters for the CommitmentTiersClient.NewListPager // method. @@ -88,7 +88,7 @@ func (client *CommitmentTiersClient) listCreateRequest(ctx context.Context, loca return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go index 7b2cb39cca98..b6be3ebb3f94 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/commitmenttiers_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListCommitmentTiers.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListCommitmentTiers.json func ExampleCommitmentTiersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go index e42f8185f42e..9cf5b2560a02 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/constants.go @@ -10,7 +10,7 @@ package armcognitiveservices const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" - moduleVersion = "v1.6.0" + moduleVersion = "v1.7.0" ) // AbusePenaltyAction - The action of AbusePenalty. @@ -43,6 +43,22 @@ func PossibleActionTypeValues() []ActionType { } } +// ByPassSelection - Setting for trusted services. +type ByPassSelection string + +const ( + ByPassSelectionAzureServices ByPassSelection = "AzureServices" + ByPassSelectionNone ByPassSelection = "None" +) + +// PossibleByPassSelectionValues returns the possible values for the ByPassSelection const type. +func PossibleByPassSelectionValues() []ByPassSelection { + return []ByPassSelection{ + ByPassSelectionAzureServices, + ByPassSelectionNone, + } +} + // CommitmentPlanProvisioningState - Gets the status of the resource at the time the operation was called. type CommitmentPlanProvisioningState string @@ -69,6 +85,24 @@ func PossibleCommitmentPlanProvisioningStateValues() []CommitmentPlanProvisionin } } +// ContentLevel - Level at which content is filtered. +type ContentLevel string + +const ( + ContentLevelHigh ContentLevel = "High" + ContentLevelLow ContentLevel = "Low" + ContentLevelMedium ContentLevel = "Medium" +) + +// PossibleContentLevelValues returns the possible values for the ContentLevel const type. +func PossibleContentLevelValues() []ContentLevel { + return []ContentLevel{ + ContentLevelHigh, + ContentLevelLow, + ContentLevelMedium, + } +} + // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -89,6 +123,22 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// DefenderForAISettingState - Defender for AI state on the AI resource. +type DefenderForAISettingState string + +const ( + DefenderForAISettingStateDisabled DefenderForAISettingState = "Disabled" + DefenderForAISettingStateEnabled DefenderForAISettingState = "Enabled" +) + +// PossibleDefenderForAISettingStateValues returns the possible values for the DefenderForAISettingState const type. +func PossibleDefenderForAISettingStateValues() []DefenderForAISettingState { + return []DefenderForAISettingState{ + DefenderForAISettingStateDisabled, + DefenderForAISettingStateEnabled, + } +} + // DeploymentModelVersionUpgradeOption - Deployment model version upgrade option. type DeploymentModelVersionUpgradeOption string @@ -151,6 +201,48 @@ func PossibleDeploymentScaleTypeValues() []DeploymentScaleType { } } +// EncryptionScopeProvisioningState - Gets the status of the resource at the time the operation was called. +type EncryptionScopeProvisioningState string + +const ( + EncryptionScopeProvisioningStateAccepted EncryptionScopeProvisioningState = "Accepted" + EncryptionScopeProvisioningStateCanceled EncryptionScopeProvisioningState = "Canceled" + EncryptionScopeProvisioningStateCreating EncryptionScopeProvisioningState = "Creating" + EncryptionScopeProvisioningStateDeleting EncryptionScopeProvisioningState = "Deleting" + EncryptionScopeProvisioningStateFailed EncryptionScopeProvisioningState = "Failed" + EncryptionScopeProvisioningStateMoving EncryptionScopeProvisioningState = "Moving" + EncryptionScopeProvisioningStateSucceeded EncryptionScopeProvisioningState = "Succeeded" +) + +// PossibleEncryptionScopeProvisioningStateValues returns the possible values for the EncryptionScopeProvisioningState const type. +func PossibleEncryptionScopeProvisioningStateValues() []EncryptionScopeProvisioningState { + return []EncryptionScopeProvisioningState{ + EncryptionScopeProvisioningStateAccepted, + EncryptionScopeProvisioningStateCanceled, + EncryptionScopeProvisioningStateCreating, + EncryptionScopeProvisioningStateDeleting, + EncryptionScopeProvisioningStateFailed, + EncryptionScopeProvisioningStateMoving, + EncryptionScopeProvisioningStateSucceeded, + } +} + +// EncryptionScopeState - The encryptionScope state. +type EncryptionScopeState string + +const ( + EncryptionScopeStateDisabled EncryptionScopeState = "Disabled" + EncryptionScopeStateEnabled EncryptionScopeState = "Enabled" +) + +// PossibleEncryptionScopeStateValues returns the possible values for the EncryptionScopeState const type. +func PossibleEncryptionScopeStateValues() []EncryptionScopeState { + return []EncryptionScopeState{ + EncryptionScopeStateDisabled, + EncryptionScopeStateEnabled, + } +} + // HostingModel - Account hosting model. type HostingModel string @@ -207,15 +299,21 @@ func PossibleKeySourceValues() []KeySource { type ModelLifecycleStatus string const ( + ModelLifecycleStatusDeprecated ModelLifecycleStatus = "Deprecated" + ModelLifecycleStatusDeprecating ModelLifecycleStatus = "Deprecating" ModelLifecycleStatusGenerallyAvailable ModelLifecycleStatus = "GenerallyAvailable" ModelLifecycleStatusPreview ModelLifecycleStatus = "Preview" + ModelLifecycleStatusStable ModelLifecycleStatus = "Stable" ) // PossibleModelLifecycleStatusValues returns the possible values for the ModelLifecycleStatus const type. func PossibleModelLifecycleStatusValues() []ModelLifecycleStatus { return []ModelLifecycleStatus{ + ModelLifecycleStatusDeprecated, + ModelLifecycleStatusDeprecating, ModelLifecycleStatusGenerallyAvailable, ModelLifecycleStatusPreview, + ModelLifecycleStatusStable, } } @@ -236,6 +334,22 @@ func PossibleNetworkRuleActionValues() []NetworkRuleAction { } } +// NspAccessRuleDirection - Direction of Access Rule +type NspAccessRuleDirection string + +const ( + NspAccessRuleDirectionInbound NspAccessRuleDirection = "Inbound" + NspAccessRuleDirectionOutbound NspAccessRuleDirection = "Outbound" +) + +// PossibleNspAccessRuleDirectionValues returns the possible values for the NspAccessRuleDirection const type. +func PossibleNspAccessRuleDirectionValues() []NspAccessRuleDirection { + return []NspAccessRuleDirection{ + NspAccessRuleDirectionInbound, + NspAccessRuleDirectionOutbound, + } +} + // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" type Origin string @@ -355,6 +469,60 @@ func PossibleQuotaUsageStatusValues() []QuotaUsageStatus { } } +// RaiPolicyContentSource - Content source to apply the Content Filters. +type RaiPolicyContentSource string + +const ( + RaiPolicyContentSourceCompletion RaiPolicyContentSource = "Completion" + RaiPolicyContentSourcePrompt RaiPolicyContentSource = "Prompt" +) + +// PossibleRaiPolicyContentSourceValues returns the possible values for the RaiPolicyContentSource const type. +func PossibleRaiPolicyContentSourceValues() []RaiPolicyContentSource { + return []RaiPolicyContentSource{ + RaiPolicyContentSourceCompletion, + RaiPolicyContentSourcePrompt, + } +} + +// RaiPolicyMode - Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, Asynchronousfilter +// =3. Please use 'Asynchronousfilter' after 2024-10-01. It is the same as 'Deferred' in +// previous version. +type RaiPolicyMode string + +const ( + RaiPolicyModeAsynchronousFilter RaiPolicyMode = "Asynchronous_filter" + RaiPolicyModeBlocking RaiPolicyMode = "Blocking" + RaiPolicyModeDefault RaiPolicyMode = "Default" + RaiPolicyModeDeferred RaiPolicyMode = "Deferred" +) + +// PossibleRaiPolicyModeValues returns the possible values for the RaiPolicyMode const type. +func PossibleRaiPolicyModeValues() []RaiPolicyMode { + return []RaiPolicyMode{ + RaiPolicyModeAsynchronousFilter, + RaiPolicyModeBlocking, + RaiPolicyModeDefault, + RaiPolicyModeDeferred, + } +} + +// RaiPolicyType - Content Filters policy type. +type RaiPolicyType string + +const ( + RaiPolicyTypeSystemManaged RaiPolicyType = "SystemManaged" + RaiPolicyTypeUserManaged RaiPolicyType = "UserManaged" +) + +// PossibleRaiPolicyTypeValues returns the possible values for the RaiPolicyType const type. +func PossibleRaiPolicyTypeValues() []RaiPolicyType { + return []RaiPolicyType{ + RaiPolicyTypeSystemManaged, + RaiPolicyTypeUserManaged, + } +} + // ResourceIdentityType - The identity type. type ResourceIdentityType string diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client.go new file mode 100644 index 000000000000..444cb8377c14 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client.go @@ -0,0 +1,327 @@ +//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 armcognitiveservices + +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" +) + +// DefenderForAISettingsClient contains the methods for the DefenderForAISettings group. +// Don't use this type directly, use NewDefenderForAISettingsClient() instead. +type DefenderForAISettingsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDefenderForAISettingsClient creates a new instance of DefenderForAISettingsClient 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 NewDefenderForAISettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefenderForAISettingsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DefenderForAISettingsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or Updates the specified Defender for AI setting. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - defenderForAISettingName - The name of the defender for AI setting. +// - defenderForAISettings - Properties describing the Defender for AI setting. +// - options - DefenderForAISettingsClientCreateOrUpdateOptions contains the optional parameters for the DefenderForAISettingsClient.CreateOrUpdate +// method. +func (client *DefenderForAISettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, defenderForAISettings DefenderForAISetting, options *DefenderForAISettingsClientCreateOrUpdateOptions) (DefenderForAISettingsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DefenderForAISettingsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, defenderForAISettingName, defenderForAISettings, options) + if err != nil { + return DefenderForAISettingsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefenderForAISettingsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefenderForAISettingsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DefenderForAISettingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, defenderForAISettings DefenderForAISetting, options *DefenderForAISettingsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if defenderForAISettingName == "" { + return nil, errors.New("parameter defenderForAISettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{defenderForAISettingName}", url.PathEscape(defenderForAISettingName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, defenderForAISettings); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DefenderForAISettingsClient) createOrUpdateHandleResponse(resp *http.Response) (DefenderForAISettingsClientCreateOrUpdateResponse, error) { + result := DefenderForAISettingsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefenderForAISetting); err != nil { + return DefenderForAISettingsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Get - Gets the specified Defender for AI setting by name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - defenderForAISettingName - The name of the defender for AI setting. +// - options - DefenderForAISettingsClientGetOptions contains the optional parameters for the DefenderForAISettingsClient.Get +// method. +func (client *DefenderForAISettingsClient) Get(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, options *DefenderForAISettingsClientGetOptions) (DefenderForAISettingsClientGetResponse, error) { + var err error + const operationName = "DefenderForAISettingsClient.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, accountName, defenderForAISettingName, options) + if err != nil { + return DefenderForAISettingsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefenderForAISettingsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefenderForAISettingsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DefenderForAISettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, options *DefenderForAISettingsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if defenderForAISettingName == "" { + return nil, errors.New("parameter defenderForAISettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{defenderForAISettingName}", url.PathEscape(defenderForAISettingName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DefenderForAISettingsClient) getHandleResponse(resp *http.Response) (DefenderForAISettingsClientGetResponse, error) { + result := DefenderForAISettingsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefenderForAISetting); err != nil { + return DefenderForAISettingsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists the Defender for AI settings. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - options - DefenderForAISettingsClientListOptions contains the optional parameters for the DefenderForAISettingsClient.NewListPager +// method. +func (client *DefenderForAISettingsClient) NewListPager(resourceGroupName string, accountName string, options *DefenderForAISettingsClientListOptions) *runtime.Pager[DefenderForAISettingsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DefenderForAISettingsClientListResponse]{ + More: func(page DefenderForAISettingsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefenderForAISettingsClientListResponse) (DefenderForAISettingsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DefenderForAISettingsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, nil) + if err != nil { + return DefenderForAISettingsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *DefenderForAISettingsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *DefenderForAISettingsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DefenderForAISettingsClient) listHandleResponse(resp *http.Response) (DefenderForAISettingsClientListResponse, error) { + result := DefenderForAISettingsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefenderForAISettingResult); err != nil { + return DefenderForAISettingsClientListResponse{}, err + } + return result, nil +} + +// Update - Updates the specified Defender for AI setting. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - defenderForAISettingName - The name of the defender for AI setting. +// - defenderForAISettings - Properties describing the Defender for AI setting. +// - options - DefenderForAISettingsClientUpdateOptions contains the optional parameters for the DefenderForAISettingsClient.Update +// method. +func (client *DefenderForAISettingsClient) Update(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, defenderForAISettings DefenderForAISetting, options *DefenderForAISettingsClientUpdateOptions) (DefenderForAISettingsClientUpdateResponse, error) { + var err error + const operationName = "DefenderForAISettingsClient.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, accountName, defenderForAISettingName, defenderForAISettings, options) + if err != nil { + return DefenderForAISettingsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefenderForAISettingsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefenderForAISettingsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *DefenderForAISettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, defenderForAISettings DefenderForAISetting, options *DefenderForAISettingsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if defenderForAISettingName == "" { + return nil, errors.New("parameter defenderForAISettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{defenderForAISettingName}", url.PathEscape(defenderForAISettingName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, defenderForAISettings); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *DefenderForAISettingsClient) updateHandleResponse(resp *http.Response) (DefenderForAISettingsClientUpdateResponse, error) { + result := DefenderForAISettingsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefenderForAISetting); err != nil { + return DefenderForAISettingsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client_example_test.go new file mode 100644 index 000000000000..cdbdf2fbabbd --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/defenderforaisettings_client_example_test.go @@ -0,0 +1,183 @@ +//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 armcognitiveservices_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/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDefenderForAISetting.json +func ExampleDefenderForAISettingsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDefenderForAISettingsClient().NewListPager("resourceGroupName", "accountName", 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.DefenderForAISettingResult = armcognitiveservices.DefenderForAISettingResult{ + // Value: []*armcognitiveservices.DefenderForAISetting{ + // { + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/defenderForAISettings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/defenderForAISettings/Default"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.DefenderForAISettingProperties{ + // State: to.Ptr(armcognitiveservices.DefenderForAISettingStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDefenderForAISetting.json +func ExampleDefenderForAISettingsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDefenderForAISettingsClient().Get(ctx, "resourceGroupName", "accountName", "Default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DefenderForAISetting = armcognitiveservices.DefenderForAISetting{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/defenderForAISettings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/defenderForAISettings/Default"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.DefenderForAISettingProperties{ + // State: to.Ptr(armcognitiveservices.DefenderForAISettingStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutDefenderForAISetting.json +func ExampleDefenderForAISettingsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDefenderForAISettingsClient().CreateOrUpdate(ctx, "resourceGroupName", "accountName", "Default", armcognitiveservices.DefenderForAISetting{ + Properties: &armcognitiveservices.DefenderForAISettingProperties{ + State: to.Ptr(armcognitiveservices.DefenderForAISettingStateEnabled), + }, + }, 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.DefenderForAISetting = armcognitiveservices.DefenderForAISetting{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/defenderForAISettings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/defenderForAISettings/Default"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.DefenderForAISettingProperties{ + // State: to.Ptr(armcognitiveservices.DefenderForAISettingStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateDefenderForAISetting.json +func ExampleDefenderForAISettingsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDefenderForAISettingsClient().Update(ctx, "resourceGroupName", "accountName", "Default", armcognitiveservices.DefenderForAISetting{ + Properties: &armcognitiveservices.DefenderForAISettingProperties{ + State: to.Ptr(armcognitiveservices.DefenderForAISettingStateEnabled), + }, + }, 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.DefenderForAISetting = armcognitiveservices.DefenderForAISetting{ + // Name: to.Ptr("Default"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/defenderForAISettings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/defenderForAISettings/Default"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.DefenderForAISettingProperties{ + // State: to.Ptr(armcognitiveservices.DefenderForAISettingStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-03T04:41:33.937Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go index f3e3acb938b2..692a0bbf6009 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client.go @@ -46,7 +46,7 @@ func NewDeletedAccountsClient(subscriptionID string, credential azcore.TokenCred // Get - Returns a Cognitive Services account specified by the parameters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - location - Resource location. // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. @@ -97,7 +97,7 @@ func (client *DeletedAccountsClient) getCreateRequest(ctx context.Context, locat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -114,7 +114,7 @@ func (client *DeletedAccountsClient) getHandleResponse(resp *http.Response) (Del // NewListPager - Returns all the resources of a particular type belonging to a subscription. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - options - DeletedAccountsClientListOptions contains the optional parameters for the DeletedAccountsClient.NewListPager // method. func (client *DeletedAccountsClient) NewListPager(options *DeletedAccountsClientListOptions) *runtime.Pager[DeletedAccountsClientListResponse] { @@ -152,7 +152,7 @@ func (client *DeletedAccountsClient) listCreateRequest(ctx context.Context, opti return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -170,7 +170,7 @@ func (client *DeletedAccountsClient) listHandleResponse(resp *http.Response) (De // BeginPurge - Deletes a Cognitive Services account from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - location - Resource location. // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. @@ -196,7 +196,7 @@ func (client *DeletedAccountsClient) BeginPurge(ctx context.Context, location st // Purge - Deletes a Cognitive Services account from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *DeletedAccountsClient) purge(ctx context.Context, location string, resourceGroupName string, accountName string, options *DeletedAccountsClientBeginPurgeOptions) (*http.Response, error) { var err error const operationName = "DeletedAccountsClient.BeginPurge" @@ -242,7 +242,7 @@ func (client *DeletedAccountsClient) purgeCreateRequest(ctx context.Context, loc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go index 35c9a5c0fc40..e336d565c8e0 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deletedaccounts_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeletedAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDeletedAccount.json func ExampleDeletedAccountsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -56,7 +56,7 @@ func ExampleDeletedAccountsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PurgeDeletedAccount.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PurgeDeletedAccount.json func ExampleDeletedAccountsClient_BeginPurge() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -77,7 +77,7 @@ func ExampleDeletedAccountsClient_BeginPurge() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListDeletedAccountsBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeletedAccountsBySubscription.json func ExampleDeletedAccountsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go index c045f05c2ee4..50c4d053a602 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client.go @@ -46,7 +46,7 @@ func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredenti // BeginCreateOrUpdate - Update the state of specified deployments associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - deploymentName - The name of the deployment associated with the Cognitive Services Account @@ -74,7 +74,7 @@ func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resour // CreateOrUpdate - Update the state of specified deployments associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, deployment Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdate" @@ -120,7 +120,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, deployment); err != nil { @@ -132,7 +132,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context // BeginDelete - Deletes the specified deployment associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - deploymentName - The name of the deployment associated with the Cognitive Services Account @@ -157,7 +157,7 @@ func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupN // Delete - Deletes the specified deployment associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDelete" @@ -203,7 +203,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -212,7 +212,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Gets the specified deployments associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - deploymentName - The name of the deployment associated with the Cognitive Services Account @@ -263,7 +263,7 @@ func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -280,7 +280,7 @@ func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (Deploym // NewListPager - Gets the deployments associated with the Cognitive Services account. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.NewListPager method. @@ -327,7 +327,7 @@ func (client *DeploymentsClient) listCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -341,3 +341,158 @@ func (client *DeploymentsClient) listHandleResponse(resp *http.Response) (Deploy } return result, nil } + +// NewListSKUsPager - Lists the specified deployments skus associated with the Cognitive Services account. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - deploymentName - The name of the deployment associated with the Cognitive Services Account +// - options - DeploymentsClientListSKUsOptions contains the optional parameters for the DeploymentsClient.NewListSKUsPager +// method. +func (client *DeploymentsClient) NewListSKUsPager(resourceGroupName string, accountName string, deploymentName string, options *DeploymentsClientListSKUsOptions) *runtime.Pager[DeploymentsClientListSKUsResponse] { + return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListSKUsResponse]{ + More: func(page DeploymentsClientListSKUsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DeploymentsClientListSKUsResponse) (DeploymentsClientListSKUsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeploymentsClient.NewListSKUsPager") + 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.listSKUsCreateRequest(ctx, resourceGroupName, accountName, deploymentName, options) + }, nil) + if err != nil { + return DeploymentsClientListSKUsResponse{}, err + } + return client.listSKUsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listSKUsCreateRequest creates the ListSKUs request. +func (client *DeploymentsClient) listSKUsCreateRequest(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, options *DeploymentsClientListSKUsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}/skus" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listSKUsHandleResponse handles the ListSKUs response. +func (client *DeploymentsClient) listSKUsHandleResponse(resp *http.Response) (DeploymentsClientListSKUsResponse, error) { + result := DeploymentsClientListSKUsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentSKUListResult); err != nil { + return DeploymentsClientListSKUsResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update specified deployments associated with the Cognitive Services account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - deploymentName - The name of the deployment associated with the Cognitive Services Account +// - deployment - The deployment properties. +// - options - DeploymentsClientBeginUpdateOptions contains the optional parameters for the DeploymentsClient.BeginUpdate method. +func (client *DeploymentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, deployment PatchResourceTagsAndSKU, options *DeploymentsClientBeginUpdateOptions) (*runtime.Poller[DeploymentsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, accountName, deploymentName, deployment, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update specified deployments associated with the Cognitive Services account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +func (client *DeploymentsClient) update(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, deployment PatchResourceTagsAndSKU, options *DeploymentsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "DeploymentsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, deploymentName, deployment, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DeploymentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, deployment PatchResourceTagsAndSKU, options *DeploymentsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentName == "" { + return nil, errors.New("parameter deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deployment); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go index a21b28844be9..4d2ea89accdf 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/deployments_client_example_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListDeployments.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeployments.json func ExampleDeploymentsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -53,17 +53,17 @@ func ExampleDeploymentsClient_NewListPager() { // Version: to.Ptr("1"), // }, // ProvisioningState: to.Ptr(armcognitiveservices.DeploymentProvisioningStateSucceeded), - // ScaleSettings: &armcognitiveservices.DeploymentScaleSettings{ - // Capacity: to.Ptr[int32](1), - // ScaleType: to.Ptr(armcognitiveservices.DeploymentScaleTypeManual), - // }, + // }, + // SKU: &armcognitiveservices.SKU{ + // Name: to.Ptr("Standard"), + // Capacity: to.Ptr[int32](1), // }, // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetDeployment.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDeployment.json func ExampleDeploymentsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -92,15 +92,15 @@ func ExampleDeploymentsClient_Get() { // Version: to.Ptr("1"), // }, // ProvisioningState: to.Ptr(armcognitiveservices.DeploymentProvisioningStateSucceeded), - // ScaleSettings: &armcognitiveservices.DeploymentScaleSettings{ - // Capacity: to.Ptr[int32](1), - // ScaleType: to.Ptr(armcognitiveservices.DeploymentScaleTypeManual), - // }, + // }, + // SKU: &armcognitiveservices.SKU{ + // Name: to.Ptr("Standard"), + // Capacity: to.Ptr[int32](1), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutDeployment.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutDeployment.json func ExampleDeploymentsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -153,7 +153,53 @@ func ExampleDeploymentsClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeleteDeployment.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateDeployment.json +func ExampleDeploymentsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDeploymentsClient().BeginUpdate(ctx, "resourceGroupName", "accountName", "deploymentName", armcognitiveservices.PatchResourceTagsAndSKU{ + SKU: &armcognitiveservices.SKU{ + Name: to.Ptr("Standard"), + Capacity: to.Ptr[int32](1), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Deployment = armcognitiveservices.Deployment{ + // Name: to.Ptr("deploymentName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/deployments"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/deployments/deploymentName"), + // Properties: &armcognitiveservices.DeploymentProperties{ + // Model: &armcognitiveservices.DeploymentModel{ + // Name: to.Ptr("ada"), + // Format: to.Ptr("OpenAI"), + // Version: to.Ptr("1"), + // }, + // ProvisioningState: to.Ptr(armcognitiveservices.DeploymentProvisioningStateSucceeded), + // }, + // SKU: &armcognitiveservices.SKU{ + // Name: to.Ptr("Standard"), + // Capacity: to.Ptr[int32](1), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteDeployment.json func ExampleDeploymentsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -173,3 +219,47 @@ func ExampleDeploymentsClient_BeginDelete() { log.Fatalf("failed to pull the result: %v", err) } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeploymentSkus.json +func ExampleDeploymentsClient_NewListSKUsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDeploymentsClient().NewListSKUsPager("resourceGroupName", "accountName", "deploymentName", 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.DeploymentSKUListResult = armcognitiveservices.DeploymentSKUListResult{ + // Value: []*armcognitiveservices.SKUResource{ + // { + // Capacity: &armcognitiveservices.CapacityConfig{ + // Default: to.Ptr[int32](100), + // AllowedValues: []*int32{ + // to.Ptr[int32](100), + // to.Ptr[int32](200)}, + // Maximum: to.Ptr[int32](1000), + // Minimum: to.Ptr[int32](100), + // Step: to.Ptr[int32](100), + // }, + // ResourceType: to.Ptr("Microsoft.CognitiveServices/accounts/deployments"), + // SKU: &armcognitiveservices.SKU{ + // Name: to.Ptr("Standard"), + // Capacity: to.Ptr[int32](1), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client.go new file mode 100644 index 000000000000..6f3b137e4a5a --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client.go @@ -0,0 +1,333 @@ +//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 armcognitiveservices + +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" +) + +// EncryptionScopesClient contains the methods for the EncryptionScopes group. +// Don't use this type directly, use NewEncryptionScopesClient() instead. +type EncryptionScopesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEncryptionScopesClient creates a new instance of EncryptionScopesClient 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 NewEncryptionScopesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EncryptionScopesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EncryptionScopesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Update the state of specified encryptionScope associated with the Cognitive Services account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - encryptionScopeName - The name of the encryptionScope associated with the Cognitive Services Account +// - encryptionScope - The encryptionScope properties. +// - options - EncryptionScopesClientCreateOrUpdateOptions contains the optional parameters for the EncryptionScopesClient.CreateOrUpdate +// method. +func (client *EncryptionScopesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesClientCreateOrUpdateOptions) (EncryptionScopesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "EncryptionScopesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, encryptionScope, options) + if err != nil { + return EncryptionScopesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EncryptionScopesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return EncryptionScopesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EncryptionScopesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if encryptionScopeName == "" { + return nil, errors.New("parameter encryptionScopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{encryptionScopeName}", url.PathEscape(encryptionScopeName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, encryptionScope); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EncryptionScopesClient) createOrUpdateHandleResponse(resp *http.Response) (EncryptionScopesClientCreateOrUpdateResponse, error) { + result := EncryptionScopesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EncryptionScope); err != nil { + return EncryptionScopesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes the specified encryptionScope associated with the Cognitive Services account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - encryptionScopeName - The name of the encryptionScope associated with the Cognitive Services Account +// - options - EncryptionScopesClientBeginDeleteOptions contains the optional parameters for the EncryptionScopesClient.BeginDelete +// method. +func (client *EncryptionScopesClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesClientBeginDeleteOptions) (*runtime.Poller[EncryptionScopesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, encryptionScopeName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EncryptionScopesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EncryptionScopesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the specified encryptionScope associated with the Cognitive Services account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +func (client *EncryptionScopesClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "EncryptionScopesClient.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, accountName, encryptionScopeName, 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 *EncryptionScopesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if encryptionScopeName == "" { + return nil, errors.New("parameter encryptionScopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{encryptionScopeName}", url.PathEscape(encryptionScopeName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the specified EncryptionScope associated with the Cognitive Services account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - encryptionScopeName - The name of the encryptionScope associated with the Cognitive Services Account +// - options - EncryptionScopesClientGetOptions contains the optional parameters for the EncryptionScopesClient.Get method. +func (client *EncryptionScopesClient) Get(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesClientGetOptions) (EncryptionScopesClientGetResponse, error) { + var err error + const operationName = "EncryptionScopesClient.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, accountName, encryptionScopeName, options) + if err != nil { + return EncryptionScopesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EncryptionScopesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EncryptionScopesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EncryptionScopesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if encryptionScopeName == "" { + return nil, errors.New("parameter encryptionScopeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{encryptionScopeName}", url.PathEscape(encryptionScopeName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EncryptionScopesClient) getHandleResponse(resp *http.Response) (EncryptionScopesClientGetResponse, error) { + result := EncryptionScopesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EncryptionScope); err != nil { + return EncryptionScopesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the content filters associated with the Azure OpenAI account. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - options - EncryptionScopesClientListOptions contains the optional parameters for the EncryptionScopesClient.NewListPager +// method. +func (client *EncryptionScopesClient) NewListPager(resourceGroupName string, accountName string, options *EncryptionScopesClientListOptions) *runtime.Pager[EncryptionScopesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[EncryptionScopesClientListResponse]{ + More: func(page EncryptionScopesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EncryptionScopesClientListResponse) (EncryptionScopesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EncryptionScopesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, nil) + if err != nil { + return EncryptionScopesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *EncryptionScopesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *EncryptionScopesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EncryptionScopesClient) listHandleResponse(resp *http.Response) (EncryptionScopesClientListResponse, error) { + result := EncryptionScopesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EncryptionScopeListResult); err != nil { + return EncryptionScopesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client_example_test.go new file mode 100644 index 000000000000..d51f3b80bebc --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/encryptionscopes_client_example_test.go @@ -0,0 +1,194 @@ +//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 armcognitiveservices_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/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListEncryptionScopes.json +func ExampleEncryptionScopesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEncryptionScopesClient().NewListPager("resourceGroupName", "accountName", 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.EncryptionScopeListResult = armcognitiveservices.EncryptionScopeListResult{ + // Value: []*armcognitiveservices.EncryptionScope{ + // { + // Name: to.Ptr("encryptionScopeName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/encryptionScopes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/encryptionScopes/encryptionScopeName"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.EncryptionScopeProperties{ + // KeySource: to.Ptr(armcognitiveservices.KeySourceMicrosoftKeyVault), + // KeyVaultProperties: &armcognitiveservices.KeyVaultProperties{ + // IdentityClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // KeyName: to.Ptr("DevKeyWestUS2"), + // KeyVaultURI: to.Ptr("https://devkvwestus2.vault.azure.net/"), + // KeyVersion: to.Ptr("9f85549d7bf14ff4bf178c10d3bdca95"), + // }, + // ProvisioningState: to.Ptr(armcognitiveservices.EncryptionScopeProvisioningStateSucceeded), + // State: to.Ptr(armcognitiveservices.EncryptionScopeStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-08T06:35:08.066Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-08T06:35:08.066Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetEncryptionScope.json +func ExampleEncryptionScopesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEncryptionScopesClient().Get(ctx, "resourceGroupName", "accountName", "encryptionScopeName", 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.EncryptionScope = armcognitiveservices.EncryptionScope{ + // Name: to.Ptr("encryptionScopeName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/encryptionScopes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/encryptionScopes/encryptionScopeName"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.EncryptionScopeProperties{ + // KeySource: to.Ptr(armcognitiveservices.KeySourceMicrosoftKeyVault), + // KeyVaultProperties: &armcognitiveservices.KeyVaultProperties{ + // IdentityClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // KeyName: to.Ptr("DevKeyWestUS2"), + // KeyVaultURI: to.Ptr("https://devkvwestus2.vault.azure.net/"), + // KeyVersion: to.Ptr("9f85549d7bf14ff4bf178c10d3bdca95"), + // }, + // ProvisioningState: to.Ptr(armcognitiveservices.EncryptionScopeProvisioningStateSucceeded), + // State: to.Ptr(armcognitiveservices.EncryptionScopeStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-08T06:35:08.066Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-08T06:35:08.066Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutEncryptionScope.json +func ExampleEncryptionScopesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEncryptionScopesClient().CreateOrUpdate(ctx, "resourceGroupName", "accountName", "encryptionScopeName", armcognitiveservices.EncryptionScope{ + Properties: &armcognitiveservices.EncryptionScopeProperties{ + KeySource: to.Ptr(armcognitiveservices.KeySourceMicrosoftKeyVault), + KeyVaultProperties: &armcognitiveservices.KeyVaultProperties{ + IdentityClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + KeyName: to.Ptr("DevKeyWestUS2"), + KeyVaultURI: to.Ptr("https://devkvwestus2.vault.azure.net/"), + KeyVersion: to.Ptr("9f85549d7bf14ff4bf178c10d3bdca95"), + }, + State: to.Ptr(armcognitiveservices.EncryptionScopeStateEnabled), + }, + }, 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.EncryptionScope = armcognitiveservices.EncryptionScope{ + // Name: to.Ptr("encryptionScopeName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/encryptionScopes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/encryptionScopes/encryptionScopeName"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.EncryptionScopeProperties{ + // KeySource: to.Ptr(armcognitiveservices.KeySourceMicrosoftKeyVault), + // KeyVaultProperties: &armcognitiveservices.KeyVaultProperties{ + // IdentityClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // KeyName: to.Ptr("DevKeyWestUS2"), + // KeyVaultURI: to.Ptr("https://devkvwestus2.vault.azure.net/"), + // KeyVersion: to.Ptr("9f85549d7bf14ff4bf178c10d3bdca95"), + // }, + // ProvisioningState: to.Ptr(armcognitiveservices.EncryptionScopeProvisioningStateSucceeded), + // State: to.Ptr(armcognitiveservices.EncryptionScopeStateEnabled), + // }, + // SystemData: &armcognitiveservices.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-08T06:35:08.066Z"); return t}()), + // CreatedBy: to.Ptr("xxx@microsoft.com"), + // CreatedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-08T06:35:08.066Z"); return t}()), + // LastModifiedBy: to.Ptr("xxx@microsoft.com"), + // LastModifiedByType: to.Ptr(armcognitiveservices.CreatedByTypeUser), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteEncryptionScope.json +func ExampleEncryptionScopesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEncryptionScopesClient().BeginDelete(ctx, "resourceGroupName", "accountName", "encryptionScopeName", 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/cognitiveservices/armcognitiveservices/fake/defenderforaisettings_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/defenderforaisettings_server.go new file mode 100644 index 000000000000..074275b11c88 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/defenderforaisettings_server.go @@ -0,0 +1,250 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// DefenderForAISettingsServer is a fake server for instances of the armcognitiveservices.DefenderForAISettingsClient type. +type DefenderForAISettingsServer struct { + // CreateOrUpdate is the fake for method DefenderForAISettingsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, defenderForAISettings armcognitiveservices.DefenderForAISetting, options *armcognitiveservices.DefenderForAISettingsClientCreateOrUpdateOptions) (resp azfake.Responder[armcognitiveservices.DefenderForAISettingsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DefenderForAISettingsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, options *armcognitiveservices.DefenderForAISettingsClientGetOptions) (resp azfake.Responder[armcognitiveservices.DefenderForAISettingsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DefenderForAISettingsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armcognitiveservices.DefenderForAISettingsClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.DefenderForAISettingsClientListResponse]) + + // Update is the fake for method DefenderForAISettingsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, accountName string, defenderForAISettingName string, defenderForAISettings armcognitiveservices.DefenderForAISetting, options *armcognitiveservices.DefenderForAISettingsClientUpdateOptions) (resp azfake.Responder[armcognitiveservices.DefenderForAISettingsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDefenderForAISettingsServerTransport creates a new instance of DefenderForAISettingsServerTransport with the provided implementation. +// The returned DefenderForAISettingsServerTransport instance is connected to an instance of armcognitiveservices.DefenderForAISettingsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDefenderForAISettingsServerTransport(srv *DefenderForAISettingsServer) *DefenderForAISettingsServerTransport { + return &DefenderForAISettingsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.DefenderForAISettingsClientListResponse]](), + } +} + +// DefenderForAISettingsServerTransport connects instances of armcognitiveservices.DefenderForAISettingsClient to instances of DefenderForAISettingsServer. +// Don't use this type directly, use NewDefenderForAISettingsServerTransport instead. +type DefenderForAISettingsServerTransport struct { + srv *DefenderForAISettingsServer + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.DefenderForAISettingsClientListResponse]] +} + +// Do implements the policy.Transporter interface for DefenderForAISettingsServerTransport. +func (d *DefenderForAISettingsServerTransport) 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 "DefenderForAISettingsClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DefenderForAISettingsClient.Get": + resp, err = d.dispatchGet(req) + case "DefenderForAISettingsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + case "DefenderForAISettingsClient.Update": + resp, err = d.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DefenderForAISettingsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/defenderForAISettings/(?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[armcognitiveservices.DefenderForAISetting](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + defenderForAISettingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("defenderForAISettingName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, accountNameParam, defenderForAISettingNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefenderForAISetting, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderForAISettingsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/defenderForAISettings/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + defenderForAISettingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("defenderForAISettingName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, accountNameParam, defenderForAISettingNameParam, 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).DefenderForAISetting, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderForAISettingsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/defenderForAISettings` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPager(resourceGroupNameParam, accountNameParam, nil) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.DefenderForAISettingsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} + +func (d *DefenderForAISettingsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if d.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/defenderForAISettings/(?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[armcognitiveservices.DefenderForAISetting](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + defenderForAISettingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("defenderForAISettingName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Update(req.Context(), resourceGroupNameParam, accountNameParam, defenderForAISettingNameParam, 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).DefenderForAISetting, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/deployments_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/deployments_server.go index 722d881e44d1..0f4ebb5e9d6b 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/deployments_server.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/deployments_server.go @@ -39,6 +39,14 @@ type DeploymentsServer struct { // NewListPager is the fake for method DeploymentsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK NewListPager func(resourceGroupName string, accountName string, options *armcognitiveservices.DeploymentsClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.DeploymentsClientListResponse]) + + // NewListSKUsPager is the fake for method DeploymentsClient.NewListSKUsPager + // HTTP status codes to indicate success: http.StatusOK + NewListSKUsPager func(resourceGroupName string, accountName string, deploymentName string, options *armcognitiveservices.DeploymentsClientListSKUsOptions) (resp azfake.PagerResponder[armcognitiveservices.DeploymentsClientListSKUsResponse]) + + // BeginUpdate is the fake for method DeploymentsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, accountName string, deploymentName string, deployment armcognitiveservices.PatchResourceTagsAndSKU, options *armcognitiveservices.DeploymentsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcognitiveservices.DeploymentsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewDeploymentsServerTransport creates a new instance of DeploymentsServerTransport with the provided implementation. @@ -50,6 +58,8 @@ func NewDeploymentsServerTransport(srv *DeploymentsServer) *DeploymentsServerTra beginCreateOrUpdate: newTracker[azfake.PollerResponder[armcognitiveservices.DeploymentsClientCreateOrUpdateResponse]](), beginDelete: newTracker[azfake.PollerResponder[armcognitiveservices.DeploymentsClientDeleteResponse]](), newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.DeploymentsClientListResponse]](), + newListSKUsPager: newTracker[azfake.PagerResponder[armcognitiveservices.DeploymentsClientListSKUsResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armcognitiveservices.DeploymentsClientUpdateResponse]](), } } @@ -60,6 +70,8 @@ type DeploymentsServerTransport struct { beginCreateOrUpdate *tracker[azfake.PollerResponder[armcognitiveservices.DeploymentsClientCreateOrUpdateResponse]] beginDelete *tracker[azfake.PollerResponder[armcognitiveservices.DeploymentsClientDeleteResponse]] newListPager *tracker[azfake.PagerResponder[armcognitiveservices.DeploymentsClientListResponse]] + newListSKUsPager *tracker[azfake.PagerResponder[armcognitiveservices.DeploymentsClientListSKUsResponse]] + beginUpdate *tracker[azfake.PollerResponder[armcognitiveservices.DeploymentsClientUpdateResponse]] } // Do implements the policy.Transporter interface for DeploymentsServerTransport. @@ -82,6 +94,10 @@ func (d *DeploymentsServerTransport) Do(req *http.Request) (*http.Response, erro resp, err = d.dispatchGet(req) case "DeploymentsClient.NewListPager": resp, err = d.dispatchNewListPager(req) + case "DeploymentsClient.NewListSKUsPager": + resp, err = d.dispatchNewListSKUsPager(req) + case "DeploymentsClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -270,3 +286,100 @@ func (d *DeploymentsServerTransport) dispatchNewListPager(req *http.Request) (*h } return resp, nil } + +func (d *DeploymentsServerTransport) dispatchNewListSKUsPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListSKUsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListSKUsPager not implemented")} + } + newListSKUsPager := d.newListSKUsPager.get(req) + if newListSKUsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListSKUsPager(resourceGroupNameParam, accountNameParam, deploymentNameParam, nil) + newListSKUsPager = &resp + d.newListSKUsPager.add(req, newListSKUsPager) + server.PagerResponderInjectNextLinks(newListSKUsPager, req, func(page *armcognitiveservices.DeploymentsClientListSKUsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListSKUsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListSKUsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListSKUsPager) { + d.newListSKUsPager.remove(req) + } + return resp, nil +} + +func (d *DeploymentsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deployments/(?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[armcognitiveservices.PatchResourceTagsAndSKU](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + deploymentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, accountNameParam, deploymentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + d.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + d.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/encryptionscopes_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/encryptionscopes_server.go new file mode 100644 index 000000000000..31d4de9c844e --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/encryptionscopes_server.go @@ -0,0 +1,259 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// EncryptionScopesServer is a fake server for instances of the armcognitiveservices.EncryptionScopesClient type. +type EncryptionScopesServer struct { + // CreateOrUpdate is the fake for method EncryptionScopesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope armcognitiveservices.EncryptionScope, options *armcognitiveservices.EncryptionScopesClientCreateOrUpdateOptions) (resp azfake.Responder[armcognitiveservices.EncryptionScopesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method EncryptionScopesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *armcognitiveservices.EncryptionScopesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcognitiveservices.EncryptionScopesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EncryptionScopesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *armcognitiveservices.EncryptionScopesClientGetOptions) (resp azfake.Responder[armcognitiveservices.EncryptionScopesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method EncryptionScopesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armcognitiveservices.EncryptionScopesClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.EncryptionScopesClientListResponse]) +} + +// NewEncryptionScopesServerTransport creates a new instance of EncryptionScopesServerTransport with the provided implementation. +// The returned EncryptionScopesServerTransport instance is connected to an instance of armcognitiveservices.EncryptionScopesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEncryptionScopesServerTransport(srv *EncryptionScopesServer) *EncryptionScopesServerTransport { + return &EncryptionScopesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armcognitiveservices.EncryptionScopesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.EncryptionScopesClientListResponse]](), + } +} + +// EncryptionScopesServerTransport connects instances of armcognitiveservices.EncryptionScopesClient to instances of EncryptionScopesServer. +// Don't use this type directly, use NewEncryptionScopesServerTransport instead. +type EncryptionScopesServerTransport struct { + srv *EncryptionScopesServer + beginDelete *tracker[azfake.PollerResponder[armcognitiveservices.EncryptionScopesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.EncryptionScopesClientListResponse]] +} + +// Do implements the policy.Transporter interface for EncryptionScopesServerTransport. +func (e *EncryptionScopesServerTransport) 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 "EncryptionScopesClient.CreateOrUpdate": + resp, err = e.dispatchCreateOrUpdate(req) + case "EncryptionScopesClient.BeginDelete": + resp, err = e.dispatchBeginDelete(req) + case "EncryptionScopesClient.Get": + resp, err = e.dispatchGet(req) + case "EncryptionScopesClient.NewListPager": + resp, err = e.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes/(?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[armcognitiveservices.EncryptionScope](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + encryptionScopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("encryptionScopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, accountNameParam, encryptionScopeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).EncryptionScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if e.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := e.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + encryptionScopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("encryptionScopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, accountNameParam, encryptionScopeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + e.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) { + e.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) { + e.beginDelete.remove(req) + } + + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + encryptionScopeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("encryptionScopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, accountNameParam, encryptionScopeNameParam, 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).EncryptionScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := e.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListPager(resourceGroupNameParam, accountNameParam, nil) + newListPager = &resp + e.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.EncryptionScopesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + e.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/locationbasedmodelcapacities_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/locationbasedmodelcapacities_server.go new file mode 100644 index 000000000000..5757004629d5 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/locationbasedmodelcapacities_server.go @@ -0,0 +1,121 @@ +//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 ( + "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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// LocationBasedModelCapacitiesServer is a fake server for instances of the armcognitiveservices.LocationBasedModelCapacitiesClient type. +type LocationBasedModelCapacitiesServer struct { + // NewListPager is the fake for method LocationBasedModelCapacitiesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(location string, modelFormat string, modelName string, modelVersion string, options *armcognitiveservices.LocationBasedModelCapacitiesClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.LocationBasedModelCapacitiesClientListResponse]) +} + +// NewLocationBasedModelCapacitiesServerTransport creates a new instance of LocationBasedModelCapacitiesServerTransport with the provided implementation. +// The returned LocationBasedModelCapacitiesServerTransport instance is connected to an instance of armcognitiveservices.LocationBasedModelCapacitiesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewLocationBasedModelCapacitiesServerTransport(srv *LocationBasedModelCapacitiesServer) *LocationBasedModelCapacitiesServerTransport { + return &LocationBasedModelCapacitiesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.LocationBasedModelCapacitiesClientListResponse]](), + } +} + +// LocationBasedModelCapacitiesServerTransport connects instances of armcognitiveservices.LocationBasedModelCapacitiesClient to instances of LocationBasedModelCapacitiesServer. +// Don't use this type directly, use NewLocationBasedModelCapacitiesServerTransport instead. +type LocationBasedModelCapacitiesServerTransport struct { + srv *LocationBasedModelCapacitiesServer + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.LocationBasedModelCapacitiesClientListResponse]] +} + +// Do implements the policy.Transporter interface for LocationBasedModelCapacitiesServerTransport. +func (l *LocationBasedModelCapacitiesServerTransport) 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 "LocationBasedModelCapacitiesClient.NewListPager": + resp, err = l.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (l *LocationBasedModelCapacitiesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := l.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/modelCapacities` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + modelFormatParam, err := url.QueryUnescape(qp.Get("modelFormat")) + if err != nil { + return nil, err + } + modelNameParam, err := url.QueryUnescape(qp.Get("modelName")) + if err != nil { + return nil, err + } + modelVersionParam, err := url.QueryUnescape(qp.Get("modelVersion")) + if err != nil { + return nil, err + } + resp := l.srv.NewListPager(locationParam, modelFormatParam, modelNameParam, modelVersionParam, nil) + newListPager = &resp + l.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.LocationBasedModelCapacitiesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + l.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + l.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/management_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/management_server.go index c97a55ed21d4..f2390e054821 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/management_server.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/management_server.go @@ -23,6 +23,10 @@ import ( // ManagementServer is a fake server for instances of the armcognitiveservices.ManagementClient type. type ManagementServer struct { + // CalculateModelCapacity is the fake for method ManagementClient.CalculateModelCapacity + // HTTP status codes to indicate success: http.StatusOK + CalculateModelCapacity func(ctx context.Context, parameters armcognitiveservices.CalculateModelCapacityParameter, options *armcognitiveservices.ManagementClientCalculateModelCapacityOptions) (resp azfake.Responder[armcognitiveservices.ManagementClientCalculateModelCapacityResponse], errResp azfake.ErrorResponder) + // CheckDomainAvailability is the fake for method ManagementClient.CheckDomainAvailability // HTTP status codes to indicate success: http.StatusOK CheckDomainAvailability func(ctx context.Context, parameters armcognitiveservices.CheckDomainAvailabilityParameter, options *armcognitiveservices.ManagementClientCheckDomainAvailabilityOptions) (resp azfake.Responder[armcognitiveservices.ManagementClientCheckDomainAvailabilityResponse], errResp azfake.ErrorResponder) @@ -57,6 +61,8 @@ func (m *ManagementServerTransport) Do(req *http.Request) (*http.Response, error var err error switch method { + case "ManagementClient.CalculateModelCapacity": + resp, err = m.dispatchCalculateModelCapacity(req) case "ManagementClient.CheckDomainAvailability": resp, err = m.dispatchCheckDomainAvailability(req) case "ManagementClient.CheckSKUAvailability": @@ -72,6 +78,35 @@ func (m *ManagementServerTransport) Do(req *http.Request) (*http.Response, error return resp, nil } +func (m *ManagementServerTransport) dispatchCalculateModelCapacity(req *http.Request) (*http.Response, error) { + if m.srv.CalculateModelCapacity == nil { + return nil, &nonRetriableError{errors.New("fake for method CalculateModelCapacity not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/calculateModelCapacity` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcognitiveservices.CalculateModelCapacityParameter](req) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CalculateModelCapacity(req.Context(), 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).CalculateModelCapacityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + func (m *ManagementServerTransport) dispatchCheckDomainAvailability(req *http.Request) (*http.Response, error) { if m.srv.CheckDomainAvailability == nil { return nil, &nonRetriableError{errors.New("fake for method CheckDomainAvailability not implemented")} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/modelcapacities_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/modelcapacities_server.go new file mode 100644 index 000000000000..63b48a39e627 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/modelcapacities_server.go @@ -0,0 +1,117 @@ +//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 ( + "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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// ModelCapacitiesServer is a fake server for instances of the armcognitiveservices.ModelCapacitiesClient type. +type ModelCapacitiesServer struct { + // NewListPager is the fake for method ModelCapacitiesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(modelFormat string, modelName string, modelVersion string, options *armcognitiveservices.ModelCapacitiesClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.ModelCapacitiesClientListResponse]) +} + +// NewModelCapacitiesServerTransport creates a new instance of ModelCapacitiesServerTransport with the provided implementation. +// The returned ModelCapacitiesServerTransport instance is connected to an instance of armcognitiveservices.ModelCapacitiesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewModelCapacitiesServerTransport(srv *ModelCapacitiesServer) *ModelCapacitiesServerTransport { + return &ModelCapacitiesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.ModelCapacitiesClientListResponse]](), + } +} + +// ModelCapacitiesServerTransport connects instances of armcognitiveservices.ModelCapacitiesClient to instances of ModelCapacitiesServer. +// Don't use this type directly, use NewModelCapacitiesServerTransport instead. +type ModelCapacitiesServerTransport struct { + srv *ModelCapacitiesServer + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.ModelCapacitiesClientListResponse]] +} + +// Do implements the policy.Transporter interface for ModelCapacitiesServerTransport. +func (m *ModelCapacitiesServerTransport) 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 "ModelCapacitiesClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ModelCapacitiesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := m.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/modelCapacities` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + modelFormatParam, err := url.QueryUnescape(qp.Get("modelFormat")) + if err != nil { + return nil, err + } + modelNameParam, err := url.QueryUnescape(qp.Get("modelName")) + if err != nil { + return nil, err + } + modelVersionParam, err := url.QueryUnescape(qp.Get("modelVersion")) + if err != nil { + return nil, err + } + resp := m.srv.NewListPager(modelFormatParam, modelNameParam, modelVersionParam, nil) + newListPager = &resp + m.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.ModelCapacitiesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + m.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/networksecurityperimeterconfigurations_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/networksecurityperimeterconfigurations_server.go new file mode 100644 index 000000000000..0e3ec6fac5c3 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/networksecurityperimeterconfigurations_server.go @@ -0,0 +1,212 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// NetworkSecurityPerimeterConfigurationsServer is a fake server for instances of the armcognitiveservices.NetworkSecurityPerimeterConfigurationsClient type. +type NetworkSecurityPerimeterConfigurationsServer struct { + // Get is the fake for method NetworkSecurityPerimeterConfigurationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientGetOptions) (resp azfake.Responder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method NetworkSecurityPerimeterConfigurationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientListResponse]) + + // BeginReconcile is the fake for method NetworkSecurityPerimeterConfigurationsClient.BeginReconcile + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginReconcile func(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (resp azfake.PollerResponder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientReconcileResponse], errResp azfake.ErrorResponder) +} + +// NewNetworkSecurityPerimeterConfigurationsServerTransport creates a new instance of NetworkSecurityPerimeterConfigurationsServerTransport with the provided implementation. +// The returned NetworkSecurityPerimeterConfigurationsServerTransport instance is connected to an instance of armcognitiveservices.NetworkSecurityPerimeterConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewNetworkSecurityPerimeterConfigurationsServerTransport(srv *NetworkSecurityPerimeterConfigurationsServer) *NetworkSecurityPerimeterConfigurationsServerTransport { + return &NetworkSecurityPerimeterConfigurationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientListResponse]](), + beginReconcile: newTracker[azfake.PollerResponder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientReconcileResponse]](), + } +} + +// NetworkSecurityPerimeterConfigurationsServerTransport connects instances of armcognitiveservices.NetworkSecurityPerimeterConfigurationsClient to instances of NetworkSecurityPerimeterConfigurationsServer. +// Don't use this type directly, use NewNetworkSecurityPerimeterConfigurationsServerTransport instead. +type NetworkSecurityPerimeterConfigurationsServerTransport struct { + srv *NetworkSecurityPerimeterConfigurationsServer + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientListResponse]] + beginReconcile *tracker[azfake.PollerResponder[armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientReconcileResponse]] +} + +// Do implements the policy.Transporter interface for NetworkSecurityPerimeterConfigurationsServerTransport. +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) 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 "NetworkSecurityPerimeterConfigurationsClient.Get": + resp, err = n.dispatchGet(req) + case "NetworkSecurityPerimeterConfigurationsClient.NewListPager": + resp, err = n.dispatchNewListPager(req) + case "NetworkSecurityPerimeterConfigurationsClient.BeginReconcile": + resp, err = n.dispatchBeginReconcile(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if n.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/networkSecurityPerimeterConfigurations/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + nspConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("nspConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := n.srv.Get(req.Context(), resourceGroupNameParam, accountNameParam, nspConfigurationNameParam, 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).NetworkSecurityPerimeterConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if n.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := n.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/networkSecurityPerimeterConfigurations` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := n.srv.NewListPager(resourceGroupNameParam, accountNameParam, nil) + newListPager = &resp + n.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.NetworkSecurityPerimeterConfigurationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + n.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + n.newListPager.remove(req) + } + return resp, nil +} + +func (n *NetworkSecurityPerimeterConfigurationsServerTransport) dispatchBeginReconcile(req *http.Request) (*http.Response, error) { + if n.srv.BeginReconcile == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginReconcile not implemented")} + } + beginReconcile := n.beginReconcile.get(req) + if beginReconcile == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/networkSecurityPerimeterConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reconcile` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + nspConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("nspConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := n.srv.BeginReconcile(req.Context(), resourceGroupNameParam, accountNameParam, nspConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginReconcile = &respr + n.beginReconcile.add(req, beginReconcile) + } + + resp, err := server.PollerResponderNext(beginReconcile, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + n.beginReconcile.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginReconcile) { + n.beginReconcile.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklistitems_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklistitems_server.go new file mode 100644 index 000000000000..3b6036763b0f --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklistitems_server.go @@ -0,0 +1,369 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// RaiBlocklistItemsServer is a fake server for instances of the armcognitiveservices.RaiBlocklistItemsClient type. +type RaiBlocklistItemsServer struct { + // BatchAdd is the fake for method RaiBlocklistItemsClient.BatchAdd + // HTTP status codes to indicate success: http.StatusOK + BatchAdd func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItems []*armcognitiveservices.RaiBlocklistItemBulkRequest, options *armcognitiveservices.RaiBlocklistItemsClientBatchAddOptions) (resp azfake.Responder[armcognitiveservices.RaiBlocklistItemsClientBatchAddResponse], errResp azfake.ErrorResponder) + + // BatchDelete is the fake for method RaiBlocklistItemsClient.BatchDelete + // HTTP status codes to indicate success: http.StatusNoContent + BatchDelete func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemsNames any, options *armcognitiveservices.RaiBlocklistItemsClientBatchDeleteOptions) (resp azfake.Responder[armcognitiveservices.RaiBlocklistItemsClientBatchDeleteResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdate is the fake for method RaiBlocklistItemsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, raiBlocklistItem armcognitiveservices.RaiBlocklistItem, options *armcognitiveservices.RaiBlocklistItemsClientCreateOrUpdateOptions) (resp azfake.Responder[armcognitiveservices.RaiBlocklistItemsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method RaiBlocklistItemsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *armcognitiveservices.RaiBlocklistItemsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcognitiveservices.RaiBlocklistItemsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RaiBlocklistItemsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *armcognitiveservices.RaiBlocklistItemsClientGetOptions) (resp azfake.Responder[armcognitiveservices.RaiBlocklistItemsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RaiBlocklistItemsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, raiBlocklistName string, options *armcognitiveservices.RaiBlocklistItemsClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.RaiBlocklistItemsClientListResponse]) +} + +// NewRaiBlocklistItemsServerTransport creates a new instance of RaiBlocklistItemsServerTransport with the provided implementation. +// The returned RaiBlocklistItemsServerTransport instance is connected to an instance of armcognitiveservices.RaiBlocklistItemsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRaiBlocklistItemsServerTransport(srv *RaiBlocklistItemsServer) *RaiBlocklistItemsServerTransport { + return &RaiBlocklistItemsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armcognitiveservices.RaiBlocklistItemsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.RaiBlocklistItemsClientListResponse]](), + } +} + +// RaiBlocklistItemsServerTransport connects instances of armcognitiveservices.RaiBlocklistItemsClient to instances of RaiBlocklistItemsServer. +// Don't use this type directly, use NewRaiBlocklistItemsServerTransport instead. +type RaiBlocklistItemsServerTransport struct { + srv *RaiBlocklistItemsServer + beginDelete *tracker[azfake.PollerResponder[armcognitiveservices.RaiBlocklistItemsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.RaiBlocklistItemsClientListResponse]] +} + +// Do implements the policy.Transporter interface for RaiBlocklistItemsServerTransport. +func (r *RaiBlocklistItemsServerTransport) 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 "RaiBlocklistItemsClient.BatchAdd": + resp, err = r.dispatchBatchAdd(req) + case "RaiBlocklistItemsClient.BatchDelete": + resp, err = r.dispatchBatchDelete(req) + case "RaiBlocklistItemsClient.CreateOrUpdate": + resp, err = r.dispatchCreateOrUpdate(req) + case "RaiBlocklistItemsClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "RaiBlocklistItemsClient.Get": + resp, err = r.dispatchGet(req) + case "RaiBlocklistItemsClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RaiBlocklistItemsServerTransport) dispatchBatchAdd(req *http.Request) (*http.Response, error) { + if r.srv.BatchAdd == nil { + return nil, &nonRetriableError{errors.New("fake for method BatchAdd not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addRaiBlocklistItems` + 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[[]*armcognitiveservices.RaiBlocklistItemBulkRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BatchAdd(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, 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).RaiBlocklist, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiBlocklistItemsServerTransport) dispatchBatchDelete(req *http.Request) (*http.Response, error) { + if r.srv.BatchDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BatchDelete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteRaiBlocklistItems` + 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[any](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BatchDelete(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiBlocklistItemsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklistItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcognitiveservices.RaiBlocklistItem](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + raiBlocklistItemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistItemName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, raiBlocklistItemNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RaiBlocklistItem, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiBlocklistItemsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklistItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + raiBlocklistItemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistItemName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, raiBlocklistItemNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.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) { + r.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) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *RaiBlocklistItemsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklistItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + raiBlocklistItemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistItemName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, raiBlocklistItemNameParam, 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).RaiBlocklistItem, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiBlocklistItemsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklistItems` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListPager(resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, nil) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.RaiBlocklistItemsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklists_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklists_server.go new file mode 100644 index 000000000000..1227d497b32a --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raiblocklists_server.go @@ -0,0 +1,259 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// RaiBlocklistsServer is a fake server for instances of the armcognitiveservices.RaiBlocklistsClient type. +type RaiBlocklistsServer struct { + // CreateOrUpdate is the fake for method RaiBlocklistsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklist armcognitiveservices.RaiBlocklist, options *armcognitiveservices.RaiBlocklistsClientCreateOrUpdateOptions) (resp azfake.Responder[armcognitiveservices.RaiBlocklistsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method RaiBlocklistsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *armcognitiveservices.RaiBlocklistsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcognitiveservices.RaiBlocklistsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RaiBlocklistsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *armcognitiveservices.RaiBlocklistsClientGetOptions) (resp azfake.Responder[armcognitiveservices.RaiBlocklistsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RaiBlocklistsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armcognitiveservices.RaiBlocklistsClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.RaiBlocklistsClientListResponse]) +} + +// NewRaiBlocklistsServerTransport creates a new instance of RaiBlocklistsServerTransport with the provided implementation. +// The returned RaiBlocklistsServerTransport instance is connected to an instance of armcognitiveservices.RaiBlocklistsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRaiBlocklistsServerTransport(srv *RaiBlocklistsServer) *RaiBlocklistsServerTransport { + return &RaiBlocklistsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armcognitiveservices.RaiBlocklistsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.RaiBlocklistsClientListResponse]](), + } +} + +// RaiBlocklistsServerTransport connects instances of armcognitiveservices.RaiBlocklistsClient to instances of RaiBlocklistsServer. +// Don't use this type directly, use NewRaiBlocklistsServerTransport instead. +type RaiBlocklistsServerTransport struct { + srv *RaiBlocklistsServer + beginDelete *tracker[azfake.PollerResponder[armcognitiveservices.RaiBlocklistsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.RaiBlocklistsClientListResponse]] +} + +// Do implements the policy.Transporter interface for RaiBlocklistsServerTransport. +func (r *RaiBlocklistsServerTransport) 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 "RaiBlocklistsClient.CreateOrUpdate": + resp, err = r.dispatchCreateOrUpdate(req) + case "RaiBlocklistsClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "RaiBlocklistsClient.Get": + resp, err = r.dispatchGet(req) + case "RaiBlocklistsClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RaiBlocklistsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?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[armcognitiveservices.RaiBlocklist](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RaiBlocklist, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiBlocklistsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.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) { + r.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) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *RaiBlocklistsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiBlocklistNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiBlocklistName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, accountNameParam, raiBlocklistNameParam, 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).RaiBlocklist, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiBlocklistsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiBlocklists` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListPager(resourceGroupNameParam, accountNameParam, nil) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.RaiBlocklistsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raicontentfilters_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raicontentfilters_server.go new file mode 100644 index 000000000000..a580a7f16f9e --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raicontentfilters_server.go @@ -0,0 +1,148 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// RaiContentFiltersServer is a fake server for instances of the armcognitiveservices.RaiContentFiltersClient type. +type RaiContentFiltersServer struct { + // Get is the fake for method RaiContentFiltersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, location string, filterName string, options *armcognitiveservices.RaiContentFiltersClientGetOptions) (resp azfake.Responder[armcognitiveservices.RaiContentFiltersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RaiContentFiltersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(location string, options *armcognitiveservices.RaiContentFiltersClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.RaiContentFiltersClientListResponse]) +} + +// NewRaiContentFiltersServerTransport creates a new instance of RaiContentFiltersServerTransport with the provided implementation. +// The returned RaiContentFiltersServerTransport instance is connected to an instance of armcognitiveservices.RaiContentFiltersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRaiContentFiltersServerTransport(srv *RaiContentFiltersServer) *RaiContentFiltersServerTransport { + return &RaiContentFiltersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.RaiContentFiltersClientListResponse]](), + } +} + +// RaiContentFiltersServerTransport connects instances of armcognitiveservices.RaiContentFiltersClient to instances of RaiContentFiltersServer. +// Don't use this type directly, use NewRaiContentFiltersServerTransport instead. +type RaiContentFiltersServerTransport struct { + srv *RaiContentFiltersServer + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.RaiContentFiltersClientListResponse]] +} + +// Do implements the policy.Transporter interface for RaiContentFiltersServerTransport. +func (r *RaiContentFiltersServerTransport) 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 "RaiContentFiltersClient.Get": + resp, err = r.dispatchGet(req) + case "RaiContentFiltersClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RaiContentFiltersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiContentFilters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + filterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("filterName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), locationParam, filterNameParam, 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).RaiContentFilter, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiContentFiltersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiContentFilters` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListPager(locationParam, nil) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.RaiContentFiltersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raipolicies_server.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raipolicies_server.go new file mode 100644 index 000000000000..1cf7f8be6b8b --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/raipolicies_server.go @@ -0,0 +1,259 @@ +//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/cognitiveservices/armcognitiveservices" + "net/http" + "net/url" + "regexp" +) + +// RaiPoliciesServer is a fake server for instances of the armcognitiveservices.RaiPoliciesClient type. +type RaiPoliciesServer struct { + // CreateOrUpdate is the fake for method RaiPoliciesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, raiPolicy armcognitiveservices.RaiPolicy, options *armcognitiveservices.RaiPoliciesClientCreateOrUpdateOptions) (resp azfake.Responder[armcognitiveservices.RaiPoliciesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method RaiPoliciesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *armcognitiveservices.RaiPoliciesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcognitiveservices.RaiPoliciesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RaiPoliciesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *armcognitiveservices.RaiPoliciesClientGetOptions) (resp azfake.Responder[armcognitiveservices.RaiPoliciesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RaiPoliciesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armcognitiveservices.RaiPoliciesClientListOptions) (resp azfake.PagerResponder[armcognitiveservices.RaiPoliciesClientListResponse]) +} + +// NewRaiPoliciesServerTransport creates a new instance of RaiPoliciesServerTransport with the provided implementation. +// The returned RaiPoliciesServerTransport instance is connected to an instance of armcognitiveservices.RaiPoliciesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRaiPoliciesServerTransport(srv *RaiPoliciesServer) *RaiPoliciesServerTransport { + return &RaiPoliciesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armcognitiveservices.RaiPoliciesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcognitiveservices.RaiPoliciesClientListResponse]](), + } +} + +// RaiPoliciesServerTransport connects instances of armcognitiveservices.RaiPoliciesClient to instances of RaiPoliciesServer. +// Don't use this type directly, use NewRaiPoliciesServerTransport instead. +type RaiPoliciesServerTransport struct { + srv *RaiPoliciesServer + beginDelete *tracker[azfake.PollerResponder[armcognitiveservices.RaiPoliciesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armcognitiveservices.RaiPoliciesClientListResponse]] +} + +// Do implements the policy.Transporter interface for RaiPoliciesServerTransport. +func (r *RaiPoliciesServerTransport) 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 "RaiPoliciesClient.CreateOrUpdate": + resp, err = r.dispatchCreateOrUpdate(req) + case "RaiPoliciesClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "RaiPoliciesClient.Get": + resp, err = r.dispatchGet(req) + case "RaiPoliciesClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RaiPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiPolicies/(?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[armcognitiveservices.RaiPolicy](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, accountNameParam, raiPolicyNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RaiPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiPoliciesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiPolicies/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameParam, accountNameParam, raiPolicyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.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) { + r.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) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *RaiPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.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\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiPolicies/(?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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + raiPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("raiPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, accountNameParam, raiPolicyNameParam, 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).RaiPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RaiPoliciesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CognitiveServices/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/raiPolicies` + 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 + } + accountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListPager(resourceGroupNameParam, accountNameParam, nil) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcognitiveservices.RaiPoliciesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/server_factory.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/server_factory.go index 717df3b8a10a..3a8efe405b8a 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/server_factory.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/server_factory.go @@ -19,18 +19,27 @@ import ( // ServerFactory is a fake server for instances of the armcognitiveservices.ClientFactory type. type ServerFactory struct { - AccountsServer AccountsServer - CommitmentPlansServer CommitmentPlansServer - CommitmentTiersServer CommitmentTiersServer - DeletedAccountsServer DeletedAccountsServer - DeploymentsServer DeploymentsServer - ManagementServer ManagementServer - ModelsServer ModelsServer - OperationsServer OperationsServer - PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer - PrivateLinkResourcesServer PrivateLinkResourcesServer - ResourceSKUsServer ResourceSKUsServer - UsagesServer UsagesServer + AccountsServer AccountsServer + CommitmentPlansServer CommitmentPlansServer + CommitmentTiersServer CommitmentTiersServer + DefenderForAISettingsServer DefenderForAISettingsServer + DeletedAccountsServer DeletedAccountsServer + DeploymentsServer DeploymentsServer + EncryptionScopesServer EncryptionScopesServer + LocationBasedModelCapacitiesServer LocationBasedModelCapacitiesServer + ManagementServer ManagementServer + ModelCapacitiesServer ModelCapacitiesServer + ModelsServer ModelsServer + NetworkSecurityPerimeterConfigurationsServer NetworkSecurityPerimeterConfigurationsServer + OperationsServer OperationsServer + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + PrivateLinkResourcesServer PrivateLinkResourcesServer + RaiBlocklistItemsServer RaiBlocklistItemsServer + RaiBlocklistsServer RaiBlocklistsServer + RaiContentFiltersServer RaiContentFiltersServer + RaiPoliciesServer RaiPoliciesServer + ResourceSKUsServer ResourceSKUsServer + UsagesServer UsagesServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -45,20 +54,29 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armcognitiveservices.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAccountsServer *AccountsServerTransport - trCommitmentPlansServer *CommitmentPlansServerTransport - trCommitmentTiersServer *CommitmentTiersServerTransport - trDeletedAccountsServer *DeletedAccountsServerTransport - trDeploymentsServer *DeploymentsServerTransport - trManagementServer *ManagementServerTransport - trModelsServer *ModelsServerTransport - trOperationsServer *OperationsServerTransport - trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport - trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport - trResourceSKUsServer *ResourceSKUsServerTransport - trUsagesServer *UsagesServerTransport + srv *ServerFactory + trMu sync.Mutex + trAccountsServer *AccountsServerTransport + trCommitmentPlansServer *CommitmentPlansServerTransport + trCommitmentTiersServer *CommitmentTiersServerTransport + trDefenderForAISettingsServer *DefenderForAISettingsServerTransport + trDeletedAccountsServer *DeletedAccountsServerTransport + trDeploymentsServer *DeploymentsServerTransport + trEncryptionScopesServer *EncryptionScopesServerTransport + trLocationBasedModelCapacitiesServer *LocationBasedModelCapacitiesServerTransport + trManagementServer *ManagementServerTransport + trModelCapacitiesServer *ModelCapacitiesServerTransport + trModelsServer *ModelsServerTransport + trNetworkSecurityPerimeterConfigurationsServer *NetworkSecurityPerimeterConfigurationsServerTransport + trOperationsServer *OperationsServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + trRaiBlocklistItemsServer *RaiBlocklistItemsServerTransport + trRaiBlocklistsServer *RaiBlocklistsServerTransport + trRaiContentFiltersServer *RaiContentFiltersServerTransport + trRaiPoliciesServer *RaiPoliciesServerTransport + trResourceSKUsServer *ResourceSKUsServerTransport + trUsagesServer *UsagesServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -87,6 +105,11 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewCommitmentTiersServerTransport(&s.srv.CommitmentTiersServer) }) resp, err = s.trCommitmentTiersServer.Do(req) + case "DefenderForAISettingsClient": + initServer(s, &s.trDefenderForAISettingsServer, func() *DefenderForAISettingsServerTransport { + return NewDefenderForAISettingsServerTransport(&s.srv.DefenderForAISettingsServer) + }) + resp, err = s.trDefenderForAISettingsServer.Do(req) case "DeletedAccountsClient": initServer(s, &s.trDeletedAccountsServer, func() *DeletedAccountsServerTransport { return NewDeletedAccountsServerTransport(&s.srv.DeletedAccountsServer) @@ -95,12 +118,32 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "DeploymentsClient": initServer(s, &s.trDeploymentsServer, func() *DeploymentsServerTransport { return NewDeploymentsServerTransport(&s.srv.DeploymentsServer) }) resp, err = s.trDeploymentsServer.Do(req) + case "EncryptionScopesClient": + initServer(s, &s.trEncryptionScopesServer, func() *EncryptionScopesServerTransport { + return NewEncryptionScopesServerTransport(&s.srv.EncryptionScopesServer) + }) + resp, err = s.trEncryptionScopesServer.Do(req) + case "LocationBasedModelCapacitiesClient": + initServer(s, &s.trLocationBasedModelCapacitiesServer, func() *LocationBasedModelCapacitiesServerTransport { + return NewLocationBasedModelCapacitiesServerTransport(&s.srv.LocationBasedModelCapacitiesServer) + }) + resp, err = s.trLocationBasedModelCapacitiesServer.Do(req) case "ManagementClient": initServer(s, &s.trManagementServer, func() *ManagementServerTransport { return NewManagementServerTransport(&s.srv.ManagementServer) }) resp, err = s.trManagementServer.Do(req) + case "ModelCapacitiesClient": + initServer(s, &s.trModelCapacitiesServer, func() *ModelCapacitiesServerTransport { + return NewModelCapacitiesServerTransport(&s.srv.ModelCapacitiesServer) + }) + resp, err = s.trModelCapacitiesServer.Do(req) case "ModelsClient": initServer(s, &s.trModelsServer, func() *ModelsServerTransport { return NewModelsServerTransport(&s.srv.ModelsServer) }) resp, err = s.trModelsServer.Do(req) + case "NetworkSecurityPerimeterConfigurationsClient": + initServer(s, &s.trNetworkSecurityPerimeterConfigurationsServer, func() *NetworkSecurityPerimeterConfigurationsServerTransport { + return NewNetworkSecurityPerimeterConfigurationsServerTransport(&s.srv.NetworkSecurityPerimeterConfigurationsServer) + }) + resp, err = s.trNetworkSecurityPerimeterConfigurationsServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) @@ -114,6 +157,24 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) }) resp, err = s.trPrivateLinkResourcesServer.Do(req) + case "RaiBlocklistItemsClient": + initServer(s, &s.trRaiBlocklistItemsServer, func() *RaiBlocklistItemsServerTransport { + return NewRaiBlocklistItemsServerTransport(&s.srv.RaiBlocklistItemsServer) + }) + resp, err = s.trRaiBlocklistItemsServer.Do(req) + case "RaiBlocklistsClient": + initServer(s, &s.trRaiBlocklistsServer, func() *RaiBlocklistsServerTransport { + return NewRaiBlocklistsServerTransport(&s.srv.RaiBlocklistsServer) + }) + resp, err = s.trRaiBlocklistsServer.Do(req) + case "RaiContentFiltersClient": + initServer(s, &s.trRaiContentFiltersServer, func() *RaiContentFiltersServerTransport { + return NewRaiContentFiltersServerTransport(&s.srv.RaiContentFiltersServer) + }) + resp, err = s.trRaiContentFiltersServer.Do(req) + case "RaiPoliciesClient": + initServer(s, &s.trRaiPoliciesServer, func() *RaiPoliciesServerTransport { return NewRaiPoliciesServerTransport(&s.srv.RaiPoliciesServer) }) + resp, err = s.trRaiPoliciesServer.Do(req) case "ResourceSKUsClient": initServer(s, &s.trResourceSKUsServer, func() *ResourceSKUsServerTransport { return NewResourceSKUsServerTransport(&s.srv.ResourceSKUsServer) }) resp, err = s.trResourceSKUsServer.Do(req) diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/time_rfc3339.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/fake/time_rfc3339.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/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/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client.go new file mode 100644 index 000000000000..514e8b3545a1 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client.go @@ -0,0 +1,110 @@ +//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 armcognitiveservices + +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" +) + +// LocationBasedModelCapacitiesClient contains the methods for the LocationBasedModelCapacities group. +// Don't use this type directly, use NewLocationBasedModelCapacitiesClient() instead. +type LocationBasedModelCapacitiesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewLocationBasedModelCapacitiesClient creates a new instance of LocationBasedModelCapacitiesClient 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 NewLocationBasedModelCapacitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationBasedModelCapacitiesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &LocationBasedModelCapacitiesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - List Location Based ModelCapacities. +// +// Generated from API version 2024-10-01 +// - location - Resource location. +// - modelFormat - The format of the Model +// - modelName - The name of the Model +// - modelVersion - The version of the Model +// - options - LocationBasedModelCapacitiesClientListOptions contains the optional parameters for the LocationBasedModelCapacitiesClient.NewListPager +// method. +func (client *LocationBasedModelCapacitiesClient) NewListPager(location string, modelFormat string, modelName string, modelVersion string, options *LocationBasedModelCapacitiesClientListOptions) *runtime.Pager[LocationBasedModelCapacitiesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[LocationBasedModelCapacitiesClientListResponse]{ + More: func(page LocationBasedModelCapacitiesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LocationBasedModelCapacitiesClientListResponse) (LocationBasedModelCapacitiesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LocationBasedModelCapacitiesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, location, modelFormat, modelName, modelVersion, options) + }, nil) + if err != nil { + return LocationBasedModelCapacitiesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *LocationBasedModelCapacitiesClient) listCreateRequest(ctx context.Context, location string, modelFormat string, modelName string, modelVersion string, options *LocationBasedModelCapacitiesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/modelCapacities" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + 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-10-01") + reqQP.Set("modelFormat", modelFormat) + reqQP.Set("modelName", modelName) + reqQP.Set("modelVersion", modelVersion) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LocationBasedModelCapacitiesClient) listHandleResponse(resp *http.Response) (LocationBasedModelCapacitiesClientListResponse, error) { + result := LocationBasedModelCapacitiesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ModelCapacityListResult); err != nil { + return LocationBasedModelCapacitiesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client_example_test.go new file mode 100644 index 000000000000..59c65490e60f --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/locationbasedmodelcapacities_client_example_test.go @@ -0,0 +1,62 @@ +//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 armcognitiveservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListLocationBasedModelCapacities.json +func ExampleLocationBasedModelCapacitiesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLocationBasedModelCapacitiesClient().NewListPager("WestUS", "OpenAI", "ada", "1", 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.ModelCapacityListResult = armcognitiveservices.ModelCapacityListResult{ + // Value: []*armcognitiveservices.ModelCapacityListResultValueItem{ + // { + // Name: to.Ptr("Standard"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/models/skuCapacities"), + // ID: to.Ptr("/subscriptions/{subscriptionContext.SubscriptionId}/providers/Microsoft.CognitiveServices/locations/WestUS/models/OpenAI.ada.1/skuCapacities/Standard"), + // Location: to.Ptr("WestUS"), + // Properties: &armcognitiveservices.ModelSKUCapacityProperties{ + // AvailableCapacity: to.Ptr[float32](300), + // AvailableFinetuneCapacity: to.Ptr[float32](20), + // Model: &armcognitiveservices.DeploymentModel{ + // Name: to.Ptr("ada"), + // Format: to.Ptr("OpenAI"), + // Version: to.Ptr("1"), + // }, + // SKUName: to.Ptr("Standard"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go index fb576233d2cc..07bfa4f2dfc3 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client.go @@ -43,10 +43,69 @@ func NewManagementClient(subscriptionID string, credential azcore.TokenCredentia return client, nil } +// CalculateModelCapacity - Model capacity calculator. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - parameters - Check Domain Availability parameter. +// - options - ManagementClientCalculateModelCapacityOptions contains the optional parameters for the ManagementClient.CalculateModelCapacity +// method. +func (client *ManagementClient) CalculateModelCapacity(ctx context.Context, parameters CalculateModelCapacityParameter, options *ManagementClientCalculateModelCapacityOptions) (ManagementClientCalculateModelCapacityResponse, error) { + var err error + const operationName = "ManagementClient.CalculateModelCapacity" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.calculateModelCapacityCreateRequest(ctx, parameters, options) + if err != nil { + return ManagementClientCalculateModelCapacityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ManagementClientCalculateModelCapacityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ManagementClientCalculateModelCapacityResponse{}, err + } + resp, err := client.calculateModelCapacityHandleResponse(httpResp) + return resp, err +} + +// calculateModelCapacityCreateRequest creates the CalculateModelCapacity request. +func (client *ManagementClient) calculateModelCapacityCreateRequest(ctx context.Context, parameters CalculateModelCapacityParameter, options *ManagementClientCalculateModelCapacityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/calculateModelCapacity" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// calculateModelCapacityHandleResponse handles the CalculateModelCapacity response. +func (client *ManagementClient) calculateModelCapacityHandleResponse(resp *http.Response) (ManagementClientCalculateModelCapacityResponse, error) { + result := ManagementClientCalculateModelCapacityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CalculateModelCapacityResult); err != nil { + return ManagementClientCalculateModelCapacityResponse{}, err + } + return result, nil +} + // CheckDomainAvailability - Check whether a domain is available. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - parameters - Check Domain Availability parameter. // - options - ManagementClientCheckDomainAvailabilityOptions contains the optional parameters for the ManagementClient.CheckDomainAvailability // method. @@ -84,7 +143,7 @@ func (client *ManagementClient) checkDomainAvailabilityCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -105,7 +164,7 @@ func (client *ManagementClient) checkDomainAvailabilityHandleResponse(resp *http // CheckSKUAvailability - Check available SKUs. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - location - Resource location. // - parameters - Check SKU Availability POST body. // - options - ManagementClientCheckSKUAvailabilityOptions contains the optional parameters for the ManagementClient.CheckSKUAvailability @@ -148,7 +207,7 @@ func (client *ManagementClient) checkSKUAvailabilityCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go index 31a6490a5fd7..40f272e2afa6 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/management_client_example_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CheckSkuAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CheckSkuAvailability.json func ExampleManagementClient_CheckSKUAvailability() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -52,7 +52,7 @@ func ExampleManagementClient_CheckSKUAvailability() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/CheckDomainAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CheckDomainAvailability.json func ExampleManagementClient_CheckDomainAvailability() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -80,3 +80,57 @@ func ExampleManagementClient_CheckDomainAvailability() { // SubdomainName: to.Ptr("contosodemoapp1"), // } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CalculateModelCapacity.json +func ExampleManagementClient_CalculateModelCapacity() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewManagementClient().CalculateModelCapacity(ctx, armcognitiveservices.CalculateModelCapacityParameter{ + Model: &armcognitiveservices.DeploymentModel{ + Name: to.Ptr("gpt-4"), + Format: to.Ptr("OpenAI"), + Version: to.Ptr("0613"), + }, + SKUName: to.Ptr("ProvisionedManaged"), + Workloads: []*armcognitiveservices.ModelCapacityCalculatorWorkload{ + { + RequestParameters: &armcognitiveservices.ModelCapacityCalculatorWorkloadRequestParam{ + AvgGeneratedTokens: to.Ptr[int64](50), + AvgPromptTokens: to.Ptr[int64](30), + }, + RequestPerMinute: to.Ptr[int64](10), + }, + { + RequestParameters: &armcognitiveservices.ModelCapacityCalculatorWorkloadRequestParam{ + AvgGeneratedTokens: to.Ptr[int64](20), + AvgPromptTokens: to.Ptr[int64](60), + }, + RequestPerMinute: to.Ptr[int64](20), + }}, + }, 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.CalculateModelCapacityResult = armcognitiveservices.CalculateModelCapacityResult{ + // EstimatedCapacity: &armcognitiveservices.CalculateModelCapacityResultEstimatedCapacity{ + // DeployableValue: to.Ptr[int32](400), + // Value: to.Ptr[int32](346), + // }, + // Model: &armcognitiveservices.DeploymentModel{ + // Name: to.Ptr("gpt-4"), + // Format: to.Ptr("OpenAI"), + // Version: to.Ptr("0613"), + // }, + // SKUName: to.Ptr("ProvisionedManaged"), + // } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client.go new file mode 100644 index 000000000000..9a4be0a60356 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client.go @@ -0,0 +1,105 @@ +//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 armcognitiveservices + +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" +) + +// ModelCapacitiesClient contains the methods for the ModelCapacities group. +// Don't use this type directly, use NewModelCapacitiesClient() instead. +type ModelCapacitiesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewModelCapacitiesClient creates a new instance of ModelCapacitiesClient 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 NewModelCapacitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ModelCapacitiesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ModelCapacitiesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - List ModelCapacities. +// +// Generated from API version 2024-10-01 +// - modelFormat - The format of the Model +// - modelName - The name of the Model +// - modelVersion - The version of the Model +// - options - ModelCapacitiesClientListOptions contains the optional parameters for the ModelCapacitiesClient.NewListPager +// method. +func (client *ModelCapacitiesClient) NewListPager(modelFormat string, modelName string, modelVersion string, options *ModelCapacitiesClientListOptions) *runtime.Pager[ModelCapacitiesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ModelCapacitiesClientListResponse]{ + More: func(page ModelCapacitiesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ModelCapacitiesClientListResponse) (ModelCapacitiesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ModelCapacitiesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, modelFormat, modelName, modelVersion, options) + }, nil) + if err != nil { + return ModelCapacitiesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ModelCapacitiesClient) listCreateRequest(ctx context.Context, modelFormat string, modelName string, modelVersion string, options *ModelCapacitiesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/modelCapacities" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-10-01") + reqQP.Set("modelFormat", modelFormat) + reqQP.Set("modelName", modelName) + reqQP.Set("modelVersion", modelVersion) + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ModelCapacitiesClient) listHandleResponse(resp *http.Response) (ModelCapacitiesClientListResponse, error) { + result := ModelCapacitiesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ModelCapacityListResult); err != nil { + return ModelCapacitiesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client_example_test.go new file mode 100644 index 000000000000..a4a7322798b1 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/modelcapacities_client_example_test.go @@ -0,0 +1,62 @@ +//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 armcognitiveservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListModelCapacities.json +func ExampleModelCapacitiesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewModelCapacitiesClient().NewListPager("OpenAI", "ada", "1", 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.ModelCapacityListResult = armcognitiveservices.ModelCapacityListResult{ + // Value: []*armcognitiveservices.ModelCapacityListResultValueItem{ + // { + // Name: to.Ptr("Standard"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/models/skuCapacities"), + // ID: to.Ptr("/subscriptions/{subscriptionContext.SubscriptionId}/providers/Microsoft.CognitiveServices/locations/WestUS/models/OpenAI.ada.1/skuCapacities/Standard"), + // Location: to.Ptr("WestUS"), + // Properties: &armcognitiveservices.ModelSKUCapacityProperties{ + // AvailableCapacity: to.Ptr[float32](300), + // AvailableFinetuneCapacity: to.Ptr[float32](20), + // Model: &armcognitiveservices.DeploymentModel{ + // Name: to.Ptr("ada"), + // Format: to.Ptr("OpenAI"), + // Version: to.Ptr("1"), + // }, + // SKUName: to.Ptr("Standard"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models.go index 813eec5fefc9..2acc95538e89 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models.go @@ -115,7 +115,7 @@ type AccountListResult struct { // AccountModel - Cognitive Services account Model. type AccountModel struct { - // Base Model Identifier. + // Properties of Cognitive Services account deployment model. BaseModel *DeploymentModel // The capabilities. @@ -142,12 +142,18 @@ type AccountModel struct { // Deployment model name. Name *string + // Deployment model publisher. + Publisher *string + // The list of Model Sku. SKUs []*ModelSKU // Optional. Deployment model source ARM resource ID. Source *string + // Optional. Source of the model, another Microsoft.CognitiveServices accounts ARM resource ID. + SourceAccount *string + // Optional. Deployment model version. If version is not specified, a default version will be assigned. The default version // is different for different models and might change when there is new version // available for a model. Default version for a model could be found from list models API. @@ -175,6 +181,9 @@ type AccountProperties struct { APIProperties *APIProperties AllowedFqdnList []*string + // The user owned AML workspace properties. + AmlWorkspace *UserOwnedAmlWorkspace + // Optional subdomain name used for token-based authentication. CustomSubDomainName *string DisableLocalAuth *bool @@ -195,7 +204,10 @@ type AccountProperties struct { NetworkACLs *NetworkRuleSet // Whether or not public endpoint access is allowed for this account. - PublicNetworkAccess *PublicNetworkAccess + PublicNetworkAccess *PublicNetworkAccess + + // Cognitive Services Rai Monitor Config. + RaiMonitorConfig *RaiMonitorConfig Restore *bool RestrictOutboundNetworkAccess *bool @@ -279,6 +291,40 @@ type AzureEntityResource struct { Type *string } +type BillingMeterInfo struct { + MeterID *string + Name *string + Unit *string +} + +// CalculateModelCapacityParameter - Calculate Model Capacity parameter. +type CalculateModelCapacityParameter struct { + // Properties of Cognitive Services account deployment model. + Model *DeploymentModel + + // The name of SKU. + SKUName *string + + // List of Model Capacity Calculator Workload. + Workloads []*ModelCapacityCalculatorWorkload +} + +// CalculateModelCapacityResult - Calculate Model Capacity result. +type CalculateModelCapacityResult struct { + // Model Estimated Capacity. + EstimatedCapacity *CalculateModelCapacityResultEstimatedCapacity + + // Properties of Cognitive Services account deployment model. + Model *DeploymentModel + SKUName *string +} + +// CalculateModelCapacityResultEstimatedCapacity - Model Estimated Capacity. +type CalculateModelCapacityResultEstimatedCapacity struct { + DeployableValue *int32 + Value *int32 +} + // CallRateLimit - The call rate limit Cognitive Services account. type CallRateLimit struct { // The count value of Call Rate Limit. @@ -291,6 +337,9 @@ type CallRateLimit struct { // CapacityConfig - The capacity configuration. type CapacityConfig struct { + // The array of allowed values for capacity. + AllowedValues []*int32 + // The default capacity. Default *int32 @@ -318,7 +367,7 @@ type CheckDomainAvailabilityParameter struct { // CheckSKUAvailabilityParameter - Check SKU availability parameter. type CheckSKUAvailabilityParameter struct { - // REQUIRED; The Kind of the resource. + // REQUIRED; The kind (type) of cognitive service account. Kind *string // REQUIRED; The SKU of the resource. @@ -393,6 +442,9 @@ type CommitmentPlanAccountAssociation struct { // Properties of Cognitive Services account commitment plan association. Properties *CommitmentPlanAccountAssociationProperties + // Resource tags. + Tags map[string]*string + // READ-ONLY; Resource Etag. Etag *string @@ -518,6 +570,57 @@ type CommitmentTierListResult struct { Value []*CommitmentTier } +// CustomBlocklistConfig - Gets or sets the source to which filter applies. +type CustomBlocklistConfig struct { + // If blocking would occur. + Blocking *bool + + // Name of ContentFilter. + BlocklistName *string + + // Content source to apply the Content Filters. + Source *RaiPolicyContentSource +} + +// DefenderForAISetting - The Defender for AI resource. +type DefenderForAISetting struct { + // The Defender for AI resource properties. + Properties *DefenderForAISettingProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource Etag. + Etag *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; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DefenderForAISettingProperties - The Defender for AI resource properties. +type DefenderForAISettingProperties struct { + // Defender for AI state on the AI resource. + State *DefenderForAISettingState +} + +// DefenderForAISettingResult - The list of cognitive services Defender for AI Settings. +type DefenderForAISettingResult struct { + // The link used to get the next page of Defender for AI Settings. + NextLink *string + + // The list of Defender for AI Settings. + Value []*DefenderForAISetting +} + // Deployment - Cognitive Services account deployment. type Deployment struct { // Properties of Cognitive Services account deployment. @@ -526,6 +629,9 @@ type Deployment struct { // The resource model definition representing SKU SKU *SKU + // Resource tags. + Tags map[string]*string + // READ-ONLY; Resource Etag. Etag *string @@ -542,6 +648,15 @@ type Deployment struct { Type *string } +// DeploymentCapacitySettings - Internal use only. +type DeploymentCapacitySettings struct { + // The designated capacity. + DesignatedCapacity *int32 + + // The priority of this capacity setting. + Priority *int32 +} + // DeploymentListResult - The list of cognitive services accounts operation response. type DeploymentListResult struct { // The link used to get the next page of Deployment. @@ -559,9 +674,15 @@ type DeploymentModel struct { // Deployment model name. Name *string + // Deployment model publisher. + Publisher *string + // Optional. Deployment model source ARM resource ID. Source *string + // Optional. Source of the model, another Microsoft.CognitiveServices accounts ARM resource ID. + SourceAccount *string + // Optional. Deployment model version. If version is not specified, a default version will be assigned. The default version // is different for different models and might change when there is new version // available for a model. Default version for a model could be found from list models API. @@ -573,13 +694,22 @@ type DeploymentModel struct { // DeploymentProperties - Properties of Cognitive Services account deployment. type DeploymentProperties struct { + // Internal use only. + CapacitySettings *DeploymentCapacitySettings + + // The current capacity. + CurrentCapacity *int32 + // Properties of Cognitive Services account deployment model. Model *DeploymentModel + // The name of parent deployment. + ParentDeploymentName *string + // The name of RAI policy. RaiPolicyName *string - // Properties of Cognitive Services account deployment model. + // Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku instead.) ScaleSettings *DeploymentScaleSettings // Deployment model version upgrade option. @@ -591,6 +721,9 @@ type DeploymentProperties struct { // READ-ONLY; The capabilities. Capabilities map[string]*string + // READ-ONLY; If the dynamic throttling is enabled. + DynamicThrottlingEnabled *bool + // READ-ONLY; Gets the status of the resource at the time the operation was called. ProvisioningState *DeploymentProvisioningState @@ -598,7 +731,17 @@ type DeploymentProperties struct { RateLimits []*ThrottlingRule } -// DeploymentScaleSettings - Properties of Cognitive Services account deployment model. +// DeploymentSKUListResult - The list of cognitive services accounts operation response. +type DeploymentSKUListResult struct { + // The link used to get the next page of deployment skus. + NextLink *string + + // READ-ONLY; Gets the list of Cognitive Services accounts deployment skus. + Value []*SKUResource +} + +// DeploymentScaleSettings - Properties of Cognitive Services account deployment model. (Deprecated, please use Deployment.sku +// instead.) type DeploymentScaleSettings struct { // Deployment capacity. Capacity *int32 @@ -637,6 +780,54 @@ type Encryption struct { KeyVaultProperties *KeyVaultProperties } +// EncryptionScope - Cognitive Services EncryptionScope +type EncryptionScope struct { + // Properties of Cognitive Services EncryptionScope. + Properties *EncryptionScopeProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource Etag. + Etag *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; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// EncryptionScopeListResult - The list of cognitive services EncryptionScopes. +type EncryptionScopeListResult struct { + // The link used to get the next page of EncryptionScope. + NextLink *string + + // The list of EncryptionScope. + Value []*EncryptionScope +} + +// EncryptionScopeProperties - Properties to EncryptionScope +type EncryptionScopeProperties struct { + // Enumerates the possible value of keySource for Encryption + KeySource *KeySource + + // Properties of KeyVault + KeyVaultProperties *KeyVaultProperties + + // The encryptionScope state. + State *EncryptionScopeState + + // READ-ONLY; Gets the status of the resource at the time the operation was called. + ProvisioningState *EncryptionScopeProvisioningState +} + // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. @@ -720,16 +911,63 @@ type MetricName struct { // Model - Cognitive Services Model. type Model struct { - // The Kind of the Model. + // The description of the model. + Description *string + + // The kind (type) of cognitive service account. Kind *string - // Model Metadata. + // Cognitive Services account Model. Model *AccountModel - // The SKU of the Model. + // The name of SKU. SKUName *string } +// ModelCapacityCalculatorWorkload - Model Capacity Calculator Workload. +type ModelCapacityCalculatorWorkload struct { + // Dictionary, Model Capacity Calculator Workload Parameters. + RequestParameters *ModelCapacityCalculatorWorkloadRequestParam + + // Request per minute. + RequestPerMinute *int64 +} + +// ModelCapacityCalculatorWorkloadRequestParam - Dictionary, Model Capacity Calculator Workload Parameters. +type ModelCapacityCalculatorWorkloadRequestParam struct { + // Average generated tokens. + AvgGeneratedTokens *int64 + + // Average prompt tokens. + AvgPromptTokens *int64 +} + +// ModelCapacityListResult - The list of cognitive services accounts operation response. +type ModelCapacityListResult struct { + // The link used to get the next page of ModelSkuCapacity. + NextLink *string + + // Gets the list of Cognitive Services accounts ModelSkuCapacity. + Value []*ModelCapacityListResultValueItem +} + +type ModelCapacityListResultValueItem struct { + // The location of the Model Sku Capacity. + Location *string + + // Cognitive Services account ModelSkuCapacity. + Properties *ModelSKUCapacityProperties + + // 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; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + // ModelDeprecationInfo - Cognitive Services account ModelDeprecationInfo. type ModelDeprecationInfo struct { // The datetime of deprecation of the fineTune Model. @@ -753,6 +991,9 @@ type ModelSKU struct { // The capacity configuration. Capacity *CapacityConfig + // The list of billing meter info. + Cost []*BillingMeterInfo + // The datetime of deprecation of the model SKU. DeprecationDate *time.Time @@ -766,6 +1007,19 @@ type ModelSKU struct { UsageName *string } +// ModelSKUCapacityProperties - Cognitive Services account ModelSkuCapacity. +type ModelSKUCapacityProperties struct { + // The available capacity for deployment with this model and sku. + AvailableCapacity *float32 + + // The available capacity for deployment with a fine-tune version of this model and sku. + AvailableFinetuneCapacity *float32 + + // Properties of Cognitive Services account deployment model. + Model *DeploymentModel + SKUName *string +} + // MultiRegionSettings - The multiregion settings Cognitive Services account. type MultiRegionSettings struct { Regions []*RegionSetting @@ -776,6 +1030,9 @@ type MultiRegionSettings struct { // NetworkRuleSet - A set of rules governing the network accessibility. type NetworkRuleSet struct { + // Setting for trusted services. + Bypass *ByPassSelection + // The default action when no rule from ipRules and from virtualNetworkRules match. This is only used after the bypass property // has been evaluated. DefaultAction *NetworkRuleAction @@ -787,6 +1044,119 @@ type NetworkRuleSet struct { VirtualNetworkRules []*VirtualNetworkRule } +// NetworkSecurityPerimeter - Information about a linked Network Security Perimeter +type NetworkSecurityPerimeter struct { + // Fully qualified identifier of the resource + ID *string + + // Location of the resource + Location *string + + // Guid of the resource + PerimeterGUID *string +} + +// NetworkSecurityPerimeterAccessRule - Network Security Perimeter Access Rule +type NetworkSecurityPerimeterAccessRule struct { + // Network Security Perimeter Access Rule Name + Name *string + + // Properties of Network Security Perimeter Access Rule + Properties *NetworkSecurityPerimeterAccessRuleProperties +} + +// NetworkSecurityPerimeterAccessRuleProperties - The Properties of Network Security Perimeter Rule +type NetworkSecurityPerimeterAccessRuleProperties struct { + // Address prefixes for inbound rules + AddressPrefixes []*string + + // Direction of Access Rule + Direction *NspAccessRuleDirection + + // Fully qualified domain name for outbound rules + FullyQualifiedDomainNames []*string + + // NetworkSecurityPerimeters for inbound rules + NetworkSecurityPerimeters []*NetworkSecurityPerimeter + + // Subscriptions for inbound rules + Subscriptions []*NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem +} + +// NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem - Subscription for inbound rule +type NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem struct { + // Fully qualified identifier of subscription + ID *string +} + +// NetworkSecurityPerimeterConfiguration - NSP Configuration for an Cognitive Services account. +type NetworkSecurityPerimeterConfiguration struct { + // NSP Configuration properties. + Properties *NetworkSecurityPerimeterConfigurationProperties + + // 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; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// NetworkSecurityPerimeterConfigurationAssociationInfo - Network Security Perimeter Configuration Association Information +type NetworkSecurityPerimeterConfigurationAssociationInfo struct { + // Access Mode of the resource association + AccessMode *string + + // Name of the resource association + Name *string +} + +// NetworkSecurityPerimeterConfigurationList - A list of NSP configurations for an Cognitive Services account. +type NetworkSecurityPerimeterConfigurationList struct { + // Link to retrieve next page of results. + NextLink *string + + // Array of NSP configurations List Result for an Cognitive Services account. + Value []*NetworkSecurityPerimeterConfiguration +} + +// NetworkSecurityPerimeterConfigurationProperties - The properties of an NSP Configuration. +type NetworkSecurityPerimeterConfigurationProperties struct { + // Information about a linked Network Security Perimeter + NetworkSecurityPerimeter *NetworkSecurityPerimeter + + // Network Security Perimeter Profile Information + Profile *NetworkSecurityPerimeterProfileInfo + + // List of Provisioning Issues + ProvisioningIssues []*ProvisioningIssue + + // Network Security Perimeter Configuration Association Information + ResourceAssociation *NetworkSecurityPerimeterConfigurationAssociationInfo + + // READ-ONLY; Provisioning state of NetworkSecurityPerimeter configuration + ProvisioningState *string +} + +// NetworkSecurityPerimeterProfileInfo - Network Security Perimeter Profile Information +type NetworkSecurityPerimeterProfileInfo struct { + AccessRules []*NetworkSecurityPerimeterAccessRule + + // Access rules version of the resource profile + AccessRulesVersion *int64 + + // Current diagnostic settings version + DiagnosticSettingsVersion *int64 + + // List of enabled log categories + EnabledLogCategories []*string + + // Name of the resource profile + Name *string +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -951,6 +1321,32 @@ type PrivateLinkServiceConnectionState struct { Status *PrivateEndpointServiceConnectionStatus } +type ProvisioningIssue struct { + // Name of the NSP provisioning issue + Name *string + + // Properties of Provisioning Issue + Properties *ProvisioningIssueProperties +} + +// ProvisioningIssueProperties - Properties of Provisioning Issue +type ProvisioningIssueProperties struct { + // Description of the issue + Description *string + + // Type of Issue + IssueType *string + + // Severity of the issue + Severity *string + + // Optional array, suggested access rules + SuggestedAccessRules []*NetworkSecurityPerimeterAccessRule + + // IDs of resources that can be associated to the same perimeter to remediate the issue. + SuggestedResourceIDs []*string +} + // ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a // location type ProxyResource struct { @@ -970,6 +1366,220 @@ type QuotaLimit struct { Rules []*ThrottlingRule } +// RaiBlockListItemsResult - The list of cognitive services RAI Blocklist Items. +type RaiBlockListItemsResult struct { + // The link used to get the next page of RaiBlocklistItems. + NextLink *string + + // The list of RaiBlocklistItems. + Value []*RaiBlocklistItem +} + +// RaiBlockListResult - The list of cognitive services RAI Blocklists. +type RaiBlockListResult struct { + // The link used to get the next page of RaiBlocklists. + NextLink *string + + // The list of RaiBlocklist. + Value []*RaiBlocklist +} + +// RaiBlocklist - Cognitive Services RaiBlocklist. +type RaiBlocklist struct { + // Properties of Cognitive Services RaiBlocklist. + Properties *RaiBlocklistProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource Etag. + Etag *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; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RaiBlocklistConfig - Azure OpenAI blocklist config. +type RaiBlocklistConfig struct { + // If blocking would occur. + Blocking *bool + + // Name of ContentFilter. + BlocklistName *string +} + +// RaiBlocklistItem - Cognitive Services RaiBlocklist Item. +type RaiBlocklistItem struct { + // Properties of Cognitive Services RaiBlocklist Item. + Properties *RaiBlocklistItemProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource Etag. + Etag *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; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RaiBlocklistItemBulkRequest - The Cognitive Services RaiBlocklist Item request body. +type RaiBlocklistItemBulkRequest struct { + Name *string + + // Properties of Cognitive Services RaiBlocklist Item. + Properties *RaiBlocklistItemProperties +} + +// RaiBlocklistItemProperties - RAI Custom Blocklist Item properties. +type RaiBlocklistItemProperties struct { + // If the pattern is a regex pattern. + IsRegex *bool + + // Pattern to match against. + Pattern *string +} + +// RaiBlocklistProperties - RAI Custom Blocklist properties. +type RaiBlocklistProperties struct { + // Description of the block list. + Description *string +} + +// RaiContentFilter - Azure OpenAI Content Filter. +type RaiContentFilter struct { + // Azure OpenAI Content Filter Properties. + Properties *RaiContentFilterProperties + + // 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; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RaiContentFilterListResult - The list of Content Filters. +type RaiContentFilterListResult struct { + // The link used to get the next page of Content Filters. + NextLink *string + + // The list of RaiContentFilter. + Value []*RaiContentFilter +} + +// RaiContentFilterProperties - Azure OpenAI Content Filter Properties. +type RaiContentFilterProperties struct { + // If the Content Filter has multi severity levels(Low, Medium, or High). + IsMultiLevelFilter *bool + + // Name of Content Filter. + Name *string + + // Content source to apply the Content Filters. + Source *RaiPolicyContentSource +} + +// RaiMonitorConfig - Cognitive Services Rai Monitor Config. +type RaiMonitorConfig struct { + // The storage resource Id. + AdxStorageResourceID *string + + // The identity client Id to access the storage. + IdentityClientID *string +} + +// RaiPolicy - Cognitive Services RaiPolicy. +type RaiPolicy struct { + // Properties of Cognitive Services RaiPolicy. + Properties *RaiPolicyProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Resource Etag. + Etag *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; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// RaiPolicyContentFilter - Azure OpenAI Content Filter. +type RaiPolicyContentFilter struct { + // If blocking would occur. + Blocking *bool + + // If the ContentFilter is enabled. + Enabled *bool + + // Name of ContentFilter. + Name *string + + // Level at which content is filtered. + SeverityThreshold *ContentLevel + + // Content source to apply the Content Filters. + Source *RaiPolicyContentSource +} + +// RaiPolicyListResult - The list of cognitive services RaiPolicies. +type RaiPolicyListResult struct { + // The link used to get the next page of RaiPolicy. + NextLink *string + + // The list of RaiPolicy. + Value []*RaiPolicy +} + +// RaiPolicyProperties - Azure OpenAI Content Filters properties. +type RaiPolicyProperties struct { + // Name of Rai policy. + BasePolicyName *string + + // The list of Content Filters. + ContentFilters []*RaiPolicyContentFilter + + // The list of custom Blocklist. + CustomBlocklists []*CustomBlocklistConfig + + // Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, Asynchronousfilter =3. Please + // use 'Asynchronousfilter' after 2024-10-01. It is the same as 'Deferred' in + // previous version. + Mode *RaiPolicyMode + + // READ-ONLY; Content Filters policy type. + Type *RaiPolicyType +} + // RegenerateKeyParameters - Regenerate key parameters. type RegenerateKeyParameters struct { // REQUIRED; key name to generate (Key1|Key2) @@ -1127,6 +1737,18 @@ type SKUChangeInfo struct { LastChangeDate *string } +// SKUResource - Properties of Cognitive Services account resource sku resource properties. +type SKUResource struct { + // The capacity configuration. + Capacity *CapacityConfig + + // The resource type name. + ResourceType *string + + // The resource model definition representing SKU + SKU *SKU +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -1199,6 +1821,15 @@ type UserAssignedIdentity struct { PrincipalID *string } +// UserOwnedAmlWorkspace - The user owned AML workspace for Cognitive Services account. +type UserOwnedAmlWorkspace struct { + // Identity Client id of a AML workspace resource. + IdentityClientID *string + + // Full resource id of a AML workspace resource. + ResourceID *string +} + // UserOwnedStorage - The user owned storage for Cognitive Services account. type UserOwnedStorage struct { IdentityClientID *string diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client.go index 820c1ced060a..ccebf9f86b24 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client.go @@ -45,7 +45,7 @@ func NewModelsClient(subscriptionID string, credential azcore.TokenCredential, o // NewListPager - List Models. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - location - Resource location. // - options - ModelsClientListOptions contains the optional parameters for the ModelsClient.NewListPager method. func (client *ModelsClient) NewListPager(location string, options *ModelsClientListOptions) *runtime.Pager[ModelsClientListResponse] { @@ -87,7 +87,7 @@ func (client *ModelsClient) listCreateRequest(ctx context.Context, location stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client_example_test.go index 810a5733545d..a7428563c875 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListModels.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListLocationModels.json func ExampleModelsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_serde.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_serde.go index 91ad242e7e20..8f2ab6234348 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_serde.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/models_serde.go @@ -270,8 +270,10 @@ func (a AccountModel) MarshalJSON() ([]byte, error) { populate(objectMap, "lifecycleStatus", a.LifecycleStatus) populate(objectMap, "maxCapacity", a.MaxCapacity) populate(objectMap, "name", a.Name) + populate(objectMap, "publisher", a.Publisher) populate(objectMap, "skus", a.SKUs) populate(objectMap, "source", a.Source) + populate(objectMap, "sourceAccount", a.SourceAccount) populate(objectMap, "systemData", a.SystemData) populate(objectMap, "version", a.Version) return json.Marshal(objectMap) @@ -316,12 +318,18 @@ func (a *AccountModel) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + delete(rawMsg, key) case "skus": err = unpopulate(val, "SKUs", &a.SKUs) delete(rawMsg, key) case "source": err = unpopulate(val, "Source", &a.Source) delete(rawMsg, key) + case "sourceAccount": + err = unpopulate(val, "SourceAccount", &a.SourceAccount) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &a.SystemData) delete(rawMsg, key) @@ -373,6 +381,7 @@ func (a AccountProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "apiProperties", a.APIProperties) populate(objectMap, "abusePenalty", a.AbusePenalty) populate(objectMap, "allowedFqdnList", a.AllowedFqdnList) + populate(objectMap, "amlWorkspace", a.AmlWorkspace) populate(objectMap, "callRateLimit", a.CallRateLimit) populate(objectMap, "capabilities", a.Capabilities) populate(objectMap, "commitmentPlanAssociations", a.CommitmentPlanAssociations) @@ -393,6 +402,7 @@ func (a AccountProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "publicNetworkAccess", a.PublicNetworkAccess) populate(objectMap, "quotaLimit", a.QuotaLimit) + populate(objectMap, "raiMonitorConfig", a.RaiMonitorConfig) populate(objectMap, "restore", a.Restore) populate(objectMap, "restrictOutboundNetworkAccess", a.RestrictOutboundNetworkAccess) populate(objectMap, "skuChangeInfo", a.SKUChangeInfo) @@ -419,6 +429,9 @@ func (a *AccountProperties) UnmarshalJSON(data []byte) error { case "allowedFqdnList": err = unpopulate(val, "AllowedFqdnList", &a.AllowedFqdnList) delete(rawMsg, key) + case "amlWorkspace": + err = unpopulate(val, "AmlWorkspace", &a.AmlWorkspace) + delete(rawMsg, key) case "callRateLimit": err = unpopulate(val, "CallRateLimit", &a.CallRateLimit) delete(rawMsg, key) @@ -479,6 +492,9 @@ func (a *AccountProperties) UnmarshalJSON(data []byte) error { case "quotaLimit": err = unpopulate(val, "QuotaLimit", &a.QuotaLimit) delete(rawMsg, key) + case "raiMonitorConfig": + err = unpopulate(val, "RaiMonitorConfig", &a.RaiMonitorConfig) + delete(rawMsg, key) case "restore": err = unpopulate(val, "Restore", &a.Restore) delete(rawMsg, key) @@ -599,6 +615,142 @@ func (a *AzureEntityResource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type BillingMeterInfo. +func (b BillingMeterInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "meterId", b.MeterID) + populate(objectMap, "name", b.Name) + populate(objectMap, "unit", b.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BillingMeterInfo. +func (b *BillingMeterInfo) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "meterId": + err = unpopulate(val, "MeterID", &b.MeterID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &b.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CalculateModelCapacityParameter. +func (c CalculateModelCapacityParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "model", c.Model) + populate(objectMap, "skuName", c.SKUName) + populate(objectMap, "workloads", c.Workloads) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CalculateModelCapacityParameter. +func (c *CalculateModelCapacityParameter) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "model": + err = unpopulate(val, "Model", &c.Model) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &c.SKUName) + delete(rawMsg, key) + case "workloads": + err = unpopulate(val, "Workloads", &c.Workloads) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CalculateModelCapacityResult. +func (c CalculateModelCapacityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "estimatedCapacity", c.EstimatedCapacity) + populate(objectMap, "model", c.Model) + populate(objectMap, "skuName", c.SKUName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CalculateModelCapacityResult. +func (c *CalculateModelCapacityResult) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "estimatedCapacity": + err = unpopulate(val, "EstimatedCapacity", &c.EstimatedCapacity) + delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &c.Model) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &c.SKUName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CalculateModelCapacityResultEstimatedCapacity. +func (c CalculateModelCapacityResultEstimatedCapacity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deployableValue", c.DeployableValue) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CalculateModelCapacityResultEstimatedCapacity. +func (c *CalculateModelCapacityResultEstimatedCapacity) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "deployableValue": + err = unpopulate(val, "DeployableValue", &c.DeployableValue) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CallRateLimit. func (c CallRateLimit) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -637,6 +789,7 @@ func (c *CallRateLimit) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CapacityConfig. func (c CapacityConfig) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "allowedValues", c.AllowedValues) populate(objectMap, "default", c.Default) populate(objectMap, "maximum", c.Maximum) populate(objectMap, "minimum", c.Minimum) @@ -653,6 +806,9 @@ func (c *CapacityConfig) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "allowedValues": + err = unpopulate(val, "AllowedValues", &c.AllowedValues) + delete(rawMsg, key) case "default": err = unpopulate(val, "Default", &c.Default) delete(rawMsg, key) @@ -888,6 +1044,7 @@ func (c CommitmentPlanAccountAssociation) MarshalJSON() ([]byte, error) { populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } @@ -916,6 +1073,9 @@ func (c *CommitmentPlanAccountAssociation) UnmarshalJSON(data []byte) error { case "systemData": err = unpopulate(val, "SystemData", &c.SystemData) delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) @@ -1223,6 +1383,150 @@ func (c *CommitmentTierListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type CustomBlocklistConfig. +func (c CustomBlocklistConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blocking", c.Blocking) + populate(objectMap, "blocklistName", c.BlocklistName) + populate(objectMap, "source", c.Source) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomBlocklistConfig. +func (c *CustomBlocklistConfig) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "blocking": + err = unpopulate(val, "Blocking", &c.Blocking) + delete(rawMsg, key) + case "blocklistName": + err = unpopulate(val, "BlocklistName", &c.BlocklistName) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderForAISetting. +func (d DefenderForAISetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", d.Etag) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForAISetting. +func (d *DefenderForAISetting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &d.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderForAISettingProperties. +func (d DefenderForAISettingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "state", d.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForAISettingProperties. +func (d *DefenderForAISettingProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "state": + err = unpopulate(val, "State", &d.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefenderForAISettingResult. +func (d DefenderForAISettingResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefenderForAISettingResult. +func (d *DefenderForAISettingResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Deployment. func (d Deployment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1232,6 +1536,7 @@ func (d Deployment) MarshalJSON() ([]byte, error) { populate(objectMap, "properties", d.Properties) populate(objectMap, "sku", d.SKU) populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } @@ -1263,6 +1568,9 @@ func (d *Deployment) UnmarshalJSON(data []byte) error { case "systemData": err = unpopulate(val, "SystemData", &d.SystemData) delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) @@ -1274,6 +1582,37 @@ func (d *Deployment) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DeploymentCapacitySettings. +func (d DeploymentCapacitySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "designatedCapacity", d.DesignatedCapacity) + populate(objectMap, "priority", d.Priority) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentCapacitySettings. +func (d *DeploymentCapacitySettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "designatedCapacity": + err = unpopulate(val, "DesignatedCapacity", &d.DesignatedCapacity) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &d.Priority) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DeploymentListResult. func (d DeploymentListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1311,7 +1650,9 @@ func (d DeploymentModel) MarshalJSON() ([]byte, error) { populate(objectMap, "callRateLimit", d.CallRateLimit) populate(objectMap, "format", d.Format) populate(objectMap, "name", d.Name) + populate(objectMap, "publisher", d.Publisher) populate(objectMap, "source", d.Source) + populate(objectMap, "sourceAccount", d.SourceAccount) populate(objectMap, "version", d.Version) return json.Marshal(objectMap) } @@ -1334,9 +1675,15 @@ func (d *DeploymentModel) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &d.Name) delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &d.Publisher) + delete(rawMsg, key) case "source": err = unpopulate(val, "Source", &d.Source) delete(rawMsg, key) + case "sourceAccount": + err = unpopulate(val, "SourceAccount", &d.SourceAccount) + delete(rawMsg, key) case "version": err = unpopulate(val, "Version", &d.Version) delete(rawMsg, key) @@ -1353,7 +1700,11 @@ func (d DeploymentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "callRateLimit", d.CallRateLimit) populate(objectMap, "capabilities", d.Capabilities) + populate(objectMap, "capacitySettings", d.CapacitySettings) + populate(objectMap, "currentCapacity", d.CurrentCapacity) + populate(objectMap, "dynamicThrottlingEnabled", d.DynamicThrottlingEnabled) populate(objectMap, "model", d.Model) + populate(objectMap, "parentDeploymentName", d.ParentDeploymentName) populate(objectMap, "provisioningState", d.ProvisioningState) populate(objectMap, "raiPolicyName", d.RaiPolicyName) populate(objectMap, "rateLimits", d.RateLimits) @@ -1377,9 +1728,21 @@ func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { case "capabilities": err = unpopulate(val, "Capabilities", &d.Capabilities) delete(rawMsg, key) + case "capacitySettings": + err = unpopulate(val, "CapacitySettings", &d.CapacitySettings) + delete(rawMsg, key) + case "currentCapacity": + err = unpopulate(val, "CurrentCapacity", &d.CurrentCapacity) + delete(rawMsg, key) + case "dynamicThrottlingEnabled": + err = unpopulate(val, "DynamicThrottlingEnabled", &d.DynamicThrottlingEnabled) + delete(rawMsg, key) case "model": err = unpopulate(val, "Model", &d.Model) delete(rawMsg, key) + case "parentDeploymentName": + err = unpopulate(val, "ParentDeploymentName", &d.ParentDeploymentName) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) delete(rawMsg, key) @@ -1403,10 +1766,41 @@ func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentScaleSettings. -func (d DeploymentScaleSettings) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DeploymentSKUListResult. +func (d DeploymentSKUListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "activeCapacity", d.ActiveCapacity) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentSKUListResult. +func (d *DeploymentSKUListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentScaleSettings. +func (d DeploymentScaleSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "activeCapacity", d.ActiveCapacity) populate(objectMap, "capacity", d.Capacity) populate(objectMap, "scaleType", d.ScaleType) return json.Marshal(objectMap) @@ -1512,6 +1906,127 @@ func (e *Encryption) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type EncryptionScope. +func (e EncryptionScope) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", e.Etag) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionScope. +func (e *EncryptionScope) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &e.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EncryptionScopeListResult. +func (e EncryptionScopeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionScopeListResult. +func (e *EncryptionScopeListResult) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EncryptionScopeProperties. +func (e EncryptionScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keySource", e.KeySource) + populate(objectMap, "keyVaultProperties", e.KeyVaultProperties) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "state", e.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionScopeProperties. +func (e *EncryptionScopeProperties) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keySource": + err = unpopulate(val, "KeySource", &e.KeySource) + delete(rawMsg, key) + case "keyVaultProperties": + err = unpopulate(val, "KeyVaultProperties", &e.KeyVaultProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &e.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1752,6 +2267,7 @@ func (m *MetricName) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Model. func (m Model) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "description", m.Description) populate(objectMap, "kind", m.Kind) populate(objectMap, "model", m.Model) populate(objectMap, "skuName", m.SKUName) @@ -1767,6 +2283,9 @@ func (m *Model) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "description": + err = unpopulate(val, "Description", &m.Description) + delete(rawMsg, key) case "kind": err = unpopulate(val, "Kind", &m.Kind) delete(rawMsg, key) @@ -1784,6 +2303,142 @@ func (m *Model) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ModelCapacityCalculatorWorkload. +func (m ModelCapacityCalculatorWorkload) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "requestParameters", m.RequestParameters) + populate(objectMap, "requestPerMinute", m.RequestPerMinute) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModelCapacityCalculatorWorkload. +func (m *ModelCapacityCalculatorWorkload) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "requestParameters": + err = unpopulate(val, "RequestParameters", &m.RequestParameters) + delete(rawMsg, key) + case "requestPerMinute": + err = unpopulate(val, "RequestPerMinute", &m.RequestPerMinute) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ModelCapacityCalculatorWorkloadRequestParam. +func (m ModelCapacityCalculatorWorkloadRequestParam) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "avgGeneratedTokens", m.AvgGeneratedTokens) + populate(objectMap, "avgPromptTokens", m.AvgPromptTokens) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModelCapacityCalculatorWorkloadRequestParam. +func (m *ModelCapacityCalculatorWorkloadRequestParam) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "avgGeneratedTokens": + err = unpopulate(val, "AvgGeneratedTokens", &m.AvgGeneratedTokens) + delete(rawMsg, key) + case "avgPromptTokens": + err = unpopulate(val, "AvgPromptTokens", &m.AvgPromptTokens) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ModelCapacityListResult. +func (m ModelCapacityListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModelCapacityListResult. +func (m *ModelCapacityListResult) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ModelCapacityListResultValueItem. +func (m ModelCapacityListResultValueItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModelCapacityListResultValueItem. +func (m *ModelCapacityListResultValueItem) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ModelDeprecationInfo. func (m ModelDeprecationInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1850,6 +2505,7 @@ func (m *ModelListResult) UnmarshalJSON(data []byte) error { func (m ModelSKU) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "capacity", m.Capacity) + populate(objectMap, "cost", m.Cost) populateDateTimeRFC3339(objectMap, "deprecationDate", m.DeprecationDate) populate(objectMap, "name", m.Name) populate(objectMap, "rateLimits", m.RateLimits) @@ -1869,6 +2525,9 @@ func (m *ModelSKU) UnmarshalJSON(data []byte) error { case "capacity": err = unpopulate(val, "Capacity", &m.Capacity) delete(rawMsg, key) + case "cost": + err = unpopulate(val, "Cost", &m.Cost) + delete(rawMsg, key) case "deprecationDate": err = unpopulateDateTimeRFC3339(val, "DeprecationDate", &m.DeprecationDate) delete(rawMsg, key) @@ -1889,6 +2548,45 @@ func (m *ModelSKU) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ModelSKUCapacityProperties. +func (m ModelSKUCapacityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availableCapacity", m.AvailableCapacity) + populate(objectMap, "availableFinetuneCapacity", m.AvailableFinetuneCapacity) + populate(objectMap, "model", m.Model) + populate(objectMap, "skuName", m.SKUName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModelSKUCapacityProperties. +func (m *ModelSKUCapacityProperties) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availableCapacity": + err = unpopulate(val, "AvailableCapacity", &m.AvailableCapacity) + delete(rawMsg, key) + case "availableFinetuneCapacity": + err = unpopulate(val, "AvailableFinetuneCapacity", &m.AvailableFinetuneCapacity) + delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &m.Model) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &m.SKUName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type MultiRegionSettings. func (m MultiRegionSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1923,6 +2621,7 @@ func (m *MultiRegionSettings) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkRuleSet. func (n NetworkRuleSet) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "bypass", n.Bypass) populate(objectMap, "defaultAction", n.DefaultAction) populate(objectMap, "ipRules", n.IPRules) populate(objectMap, "virtualNetworkRules", n.VirtualNetworkRules) @@ -1938,6 +2637,9 @@ func (n *NetworkRuleSet) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "bypass": + err = unpopulate(val, "Bypass", &n.Bypass) + delete(rawMsg, key) case "defaultAction": err = unpopulate(val, "DefaultAction", &n.DefaultAction) delete(rawMsg, key) @@ -1955,10 +2657,333 @@ func (n *NetworkRuleSet) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeter. +func (n NetworkSecurityPerimeter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "perimeterGuid", n.PerimeterGUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeter. +func (n *NetworkSecurityPerimeter) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "perimeterGuid": + err = unpopulate(val, "PerimeterGUID", &n.PerimeterGUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterAccessRule. +func (n NetworkSecurityPerimeterAccessRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterAccessRule. +func (n *NetworkSecurityPerimeterAccessRule) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterAccessRuleProperties. +func (n NetworkSecurityPerimeterAccessRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressPrefixes", n.AddressPrefixes) + populate(objectMap, "direction", n.Direction) + populate(objectMap, "fullyQualifiedDomainNames", n.FullyQualifiedDomainNames) + populate(objectMap, "networkSecurityPerimeters", n.NetworkSecurityPerimeters) + populate(objectMap, "subscriptions", n.Subscriptions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterAccessRuleProperties. +func (n *NetworkSecurityPerimeterAccessRuleProperties) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressPrefixes": + err = unpopulate(val, "AddressPrefixes", &n.AddressPrefixes) + delete(rawMsg, key) + case "direction": + err = unpopulate(val, "Direction", &n.Direction) + delete(rawMsg, key) + case "fullyQualifiedDomainNames": + err = unpopulate(val, "FullyQualifiedDomainNames", &n.FullyQualifiedDomainNames) + delete(rawMsg, key) + case "networkSecurityPerimeters": + err = unpopulate(val, "NetworkSecurityPerimeters", &n.NetworkSecurityPerimeters) + delete(rawMsg, key) + case "subscriptions": + err = unpopulate(val, "Subscriptions", &n.Subscriptions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem. +func (n NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem. +func (n *NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfiguration. +func (n NetworkSecurityPerimeterConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", n.ID) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfiguration. +func (n *NetworkSecurityPerimeterConfiguration) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfigurationAssociationInfo. +func (n NetworkSecurityPerimeterConfigurationAssociationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessMode", n.AccessMode) + populate(objectMap, "name", n.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfigurationAssociationInfo. +func (n *NetworkSecurityPerimeterConfigurationAssociationInfo) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accessMode": + err = unpopulate(val, "AccessMode", &n.AccessMode) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfigurationList. +func (n NetworkSecurityPerimeterConfigurationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfigurationList. +func (n *NetworkSecurityPerimeterConfigurationList) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &n.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &n.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterConfigurationProperties. +func (n NetworkSecurityPerimeterConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "networkSecurityPerimeter", n.NetworkSecurityPerimeter) + populate(objectMap, "profile", n.Profile) + populate(objectMap, "provisioningIssues", n.ProvisioningIssues) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "resourceAssociation", n.ResourceAssociation) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterConfigurationProperties. +func (n *NetworkSecurityPerimeterConfigurationProperties) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "networkSecurityPerimeter": + err = unpopulate(val, "NetworkSecurityPerimeter", &n.NetworkSecurityPerimeter) + delete(rawMsg, key) + case "profile": + err = unpopulate(val, "Profile", &n.Profile) + delete(rawMsg, key) + case "provisioningIssues": + err = unpopulate(val, "ProvisioningIssues", &n.ProvisioningIssues) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) + case "resourceAssociation": + err = unpopulate(val, "ResourceAssociation", &n.ResourceAssociation) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkSecurityPerimeterProfileInfo. +func (n NetworkSecurityPerimeterProfileInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessRules", n.AccessRules) + populate(objectMap, "accessRulesVersion", n.AccessRulesVersion) + populate(objectMap, "diagnosticSettingsVersion", n.DiagnosticSettingsVersion) + populate(objectMap, "enabledLogCategories", n.EnabledLogCategories) + populate(objectMap, "name", n.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSecurityPerimeterProfileInfo. +func (n *NetworkSecurityPerimeterProfileInfo) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accessRules": + err = unpopulate(val, "AccessRules", &n.AccessRules) + delete(rawMsg, key) + case "accessRulesVersion": + err = unpopulate(val, "AccessRulesVersion", &n.AccessRulesVersion) + delete(rawMsg, key) + case "diagnosticSettingsVersion": + err = unpopulate(val, "DiagnosticSettingsVersion", &n.DiagnosticSettingsVersion) + delete(rawMsg, key) + case "enabledLogCategories": + err = unpopulate(val, "EnabledLogCategories", &n.EnabledLogCategories) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -2198,283 +3223,945 @@ func (p *PrivateEndpointConnection) UnmarshalJSON(data []byte) error { delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionListResult. +func (p *PrivateEndpointConnectionListResult) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. +func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "groupIds", p.GroupIDs) + populate(objectMap, "privateEndpoint", p.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionProperties. +func (p *PrivateEndpointConnectionProperties) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "groupIds": + err = unpopulate(val, "GroupIDs", &p.GroupIDs) + delete(rawMsg, key) + case "privateEndpoint": + err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) + delete(rawMsg, key) + case "privateLinkServiceConnectionState": + err = unpopulate(val, "PrivateLinkServiceConnectionState", &p.PrivateLinkServiceConnectionState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. +func (p *PrivateLinkResource) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. +func (p *PrivateLinkResourceListResult) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. +func (p *PrivateLinkResourceProperties) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "groupId": + err = unpopulate(val, "GroupID", &p.GroupID) + delete(rawMsg, key) + case "requiredMembers": + err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + delete(rawMsg, key) + case "requiredZoneNames": + err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. +func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionsRequired", p.ActionsRequired) + populate(objectMap, "description", p.Description) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. +func (p *PrivateLinkServiceConnectionState) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionsRequired": + err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisioningIssue. +func (p ProvisioningIssue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisioningIssue. +func (p *ProvisioningIssue) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisioningIssueProperties. +func (p ProvisioningIssueProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", p.Description) + populate(objectMap, "issueType", p.IssueType) + populate(objectMap, "severity", p.Severity) + populate(objectMap, "suggestedAccessRules", p.SuggestedAccessRules) + populate(objectMap, "suggestedResourceIds", p.SuggestedResourceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisioningIssueProperties. +func (p *ProvisioningIssueProperties) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "issueType": + err = unpopulate(val, "IssueType", &p.IssueType) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &p.Severity) + delete(rawMsg, key) + case "suggestedAccessRules": + err = unpopulate(val, "SuggestedAccessRules", &p.SuggestedAccessRules) + delete(rawMsg, key) + case "suggestedResourceIds": + err = unpopulate(val, "SuggestedResourceIDs", &p.SuggestedResourceIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) 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", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaLimit. +func (q QuotaLimit) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", q.Count) + populate(objectMap, "renewalPeriod", q.RenewalPeriod) + populate(objectMap, "rules", q.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaLimit. +func (q *QuotaLimit) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &q.Count) + delete(rawMsg, key) + case "renewalPeriod": + err = unpopulate(val, "RenewalPeriod", &q.RenewalPeriod) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &q.Rules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlockListItemsResult. +func (r RaiBlockListItemsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlockListItemsResult. +func (r *RaiBlockListItemsResult) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlockListResult. +func (r RaiBlockListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlockListResult. +func (r *RaiBlockListResult) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlocklist. +func (r RaiBlocklist) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlocklist. +func (r *RaiBlocklist) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlocklistConfig. +func (r RaiBlocklistConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blocking", r.Blocking) + populate(objectMap, "blocklistName", r.BlocklistName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlocklistConfig. +func (r *RaiBlocklistConfig) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "blocking": + err = unpopulate(val, "Blocking", &r.Blocking) + delete(rawMsg, key) + case "blocklistName": + err = unpopulate(val, "BlocklistName", &r.BlocklistName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlocklistItem. +func (r RaiBlocklistItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlocklistItem. +func (r *RaiBlocklistItem) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlocklistItemBulkRequest. +func (r RaiBlocklistItemBulkRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlocklistItemBulkRequest. +func (r *RaiBlocklistItemBulkRequest) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlocklistItemProperties. +func (r RaiBlocklistItemProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isRegex", r.IsRegex) + populate(objectMap, "pattern", r.Pattern) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlocklistItemProperties. +func (r *RaiBlocklistItemProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "isRegex": + err = unpopulate(val, "IsRegex", &r.IsRegex) + delete(rawMsg, key) + case "pattern": + err = unpopulate(val, "Pattern", &r.Pattern) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RaiBlocklistProperties. +func (r RaiBlocklistProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", r.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiBlocklistProperties. +func (r *RaiBlocklistProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. -func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiContentFilter. +func (r RaiContentFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "value", p.Value) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionListResult. -func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiContentFilter. +func (r *RaiContentFilter) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "value": - err = unpopulate(val, "Value", &p.Value) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. -func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiContentFilterListResult. +func (r RaiContentFilterListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "groupIds", p.GroupIDs) - populate(objectMap, "privateEndpoint", p.PrivateEndpoint) - populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) - populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateEndpointConnectionProperties. -func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiContentFilterListResult. +func (r *RaiContentFilterListResult) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "groupIds": - err = unpopulate(val, "GroupIDs", &p.GroupIDs) - delete(rawMsg, key) - case "privateEndpoint": - err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) - delete(rawMsg, key) - case "privateLinkServiceConnectionState": - err = unpopulate(val, "PrivateLinkServiceConnectionState", &p.PrivateLinkServiceConnectionState) + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + case "value": + err = unpopulate(val, "Value", &r.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. -func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiContentFilterProperties. +func (r RaiContentFilterProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "type", p.Type) + populate(objectMap, "isMultiLevelFilter", r.IsMultiLevelFilter) + populate(objectMap, "name", r.Name) + populate(objectMap, "source", r.Source) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResource. -func (p *PrivateLinkResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiContentFilterProperties. +func (r *RaiContentFilterProperties) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) + case "isMultiLevelFilter": + err = unpopulate(val, "IsMultiLevelFilter", &r.IsMultiLevelFilter) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &p.Properties) + err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "source": + err = unpopulate(val, "Source", &r.Source) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. -func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiMonitorConfig. +func (r RaiMonitorConfig) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "value", p.Value) + populate(objectMap, "adxStorageResourceId", r.AdxStorageResourceID) + populate(objectMap, "identityClientId", r.IdentityClientID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceListResult. -func (p *PrivateLinkResourceListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiMonitorConfig. +func (r *RaiMonitorConfig) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "value": - err = unpopulate(val, "Value", &p.Value) + case "adxStorageResourceId": + err = unpopulate(val, "AdxStorageResourceID", &r.AdxStorageResourceID) + delete(rawMsg, key) + case "identityClientId": + err = unpopulate(val, "IdentityClientID", &r.IdentityClientID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. -func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiPolicy. +func (r RaiPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "displayName", p.DisplayName) - populate(objectMap, "groupId", p.GroupID) - populate(objectMap, "requiredMembers", p.RequiredMembers) - populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkResourceProperties. -func (p *PrivateLinkResourceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiPolicy. +func (r *RaiPolicy) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "displayName": - err = unpopulate(val, "DisplayName", &p.DisplayName) + case "etag": + err = unpopulate(val, "Etag", &r.Etag) delete(rawMsg, key) - case "groupId": - err = unpopulate(val, "GroupID", &p.GroupID) + case "id": + err = unpopulate(val, "ID", &r.ID) delete(rawMsg, key) - case "requiredMembers": - err = unpopulate(val, "RequiredMembers", &p.RequiredMembers) + case "name": + err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) - case "requiredZoneNames": - err = unpopulate(val, "RequiredZoneNames", &p.RequiredZoneNames) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type PrivateLinkServiceConnectionState. -func (p PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiPolicyContentFilter. +func (r RaiPolicyContentFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "actionsRequired", p.ActionsRequired) - populate(objectMap, "description", p.Description) - populate(objectMap, "status", p.Status) + populate(objectMap, "blocking", r.Blocking) + populate(objectMap, "enabled", r.Enabled) + populate(objectMap, "name", r.Name) + populate(objectMap, "severityThreshold", r.SeverityThreshold) + populate(objectMap, "source", r.Source) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateLinkServiceConnectionState. -func (p *PrivateLinkServiceConnectionState) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiPolicyContentFilter. +func (r *RaiPolicyContentFilter) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "actionsRequired": - err = unpopulate(val, "ActionsRequired", &p.ActionsRequired) + case "blocking": + err = unpopulate(val, "Blocking", &r.Blocking) delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &p.Description) + case "enabled": + err = unpopulate(val, "Enabled", &r.Enabled) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "severityThreshold": + err = unpopulate(val, "SeverityThreshold", &r.SeverityThreshold) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &r.Source) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProxyResource. -func (p ProxyResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiPolicyListResult. +func (r RaiPolicyListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "type", p.Type) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. -func (p *ProxyResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiPolicyListResult. +func (r *RaiPolicyListResult) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "value": + err = unpopulate(val, "Value", &r.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type QuotaLimit. -func (q QuotaLimit) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RaiPolicyProperties. +func (r RaiPolicyProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", q.Count) - populate(objectMap, "renewalPeriod", q.RenewalPeriod) - populate(objectMap, "rules", q.Rules) + populate(objectMap, "basePolicyName", r.BasePolicyName) + populate(objectMap, "contentFilters", r.ContentFilters) + populate(objectMap, "customBlocklists", r.CustomBlocklists) + populate(objectMap, "mode", r.Mode) + populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaLimit. -func (q *QuotaLimit) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RaiPolicyProperties. +func (r *RaiPolicyProperties) 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", q, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &q.Count) + case "basePolicyName": + err = unpopulate(val, "BasePolicyName", &r.BasePolicyName) delete(rawMsg, key) - case "renewalPeriod": - err = unpopulate(val, "RenewalPeriod", &q.RenewalPeriod) + case "contentFilters": + err = unpopulate(val, "ContentFilters", &r.ContentFilters) delete(rawMsg, key) - case "rules": - err = unpopulate(val, "Rules", &q.Rules) + case "customBlocklists": + err = unpopulate(val, "CustomBlocklists", &r.CustomBlocklists) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &r.Mode) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", q, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil @@ -2939,6 +4626,41 @@ func (s *SKUChangeInfo) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SKUResource. +func (s SKUResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "sku", s.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUResource. +func (s *SKUResource) 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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &s.ResourceType) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + 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) @@ -3146,6 +4868,37 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type UserOwnedAmlWorkspace. +func (u UserOwnedAmlWorkspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identityClientId", u.IdentityClientID) + populate(objectMap, "resourceId", u.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserOwnedAmlWorkspace. +func (u *UserOwnedAmlWorkspace) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identityClientId": + err = unpopulate(val, "IdentityClientID", &u.IdentityClientID) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &u.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type UserOwnedStorage. func (u UserOwnedStorage) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3233,7 +4986,7 @@ func populateAny(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/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client.go new file mode 100644 index 000000000000..5387c0dbd184 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client.go @@ -0,0 +1,261 @@ +//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 armcognitiveservices + +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" +) + +// NetworkSecurityPerimeterConfigurationsClient contains the methods for the NetworkSecurityPerimeterConfigurations group. +// Don't use this type directly, use NewNetworkSecurityPerimeterConfigurationsClient() instead. +type NetworkSecurityPerimeterConfigurationsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewNetworkSecurityPerimeterConfigurationsClient creates a new instance of NetworkSecurityPerimeterConfigurationsClient 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 NewNetworkSecurityPerimeterConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NetworkSecurityPerimeterConfigurationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &NetworkSecurityPerimeterConfigurationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the specified NSP configurations for an account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - nspConfigurationName - The name of the NSP Configuration. +// - options - NetworkSecurityPerimeterConfigurationsClientGetOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.Get +// method. +func (client *NetworkSecurityPerimeterConfigurationsClient) Get(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientGetOptions) (NetworkSecurityPerimeterConfigurationsClientGetResponse, error) { + var err error + const operationName = "NetworkSecurityPerimeterConfigurationsClient.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, accountName, nspConfigurationName, options) + if err != nil { + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *NetworkSecurityPerimeterConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if nspConfigurationName == "" { + return nil, errors.New("parameter nspConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{nspConfigurationName}", url.PathEscape(nspConfigurationName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NetworkSecurityPerimeterConfigurationsClient) getHandleResponse(resp *http.Response) (NetworkSecurityPerimeterConfigurationsClientGetResponse, error) { + result := NetworkSecurityPerimeterConfigurationsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkSecurityPerimeterConfiguration); err != nil { + return NetworkSecurityPerimeterConfigurationsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets a list of NSP configurations for an account. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - options - NetworkSecurityPerimeterConfigurationsClientListOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.NewListPager +// method. +func (client *NetworkSecurityPerimeterConfigurationsClient) NewListPager(resourceGroupName string, accountName string, options *NetworkSecurityPerimeterConfigurationsClientListOptions) *runtime.Pager[NetworkSecurityPerimeterConfigurationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[NetworkSecurityPerimeterConfigurationsClientListResponse]{ + More: func(page NetworkSecurityPerimeterConfigurationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *NetworkSecurityPerimeterConfigurationsClientListResponse) (NetworkSecurityPerimeterConfigurationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "NetworkSecurityPerimeterConfigurationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, nil) + if err != nil { + return NetworkSecurityPerimeterConfigurationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *NetworkSecurityPerimeterConfigurationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *NetworkSecurityPerimeterConfigurationsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *NetworkSecurityPerimeterConfigurationsClient) listHandleResponse(resp *http.Response) (NetworkSecurityPerimeterConfigurationsClientListResponse, error) { + result := NetworkSecurityPerimeterConfigurationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkSecurityPerimeterConfigurationList); err != nil { + return NetworkSecurityPerimeterConfigurationsClientListResponse{}, err + } + return result, nil +} + +// BeginReconcile - Reconcile the NSP configuration for an account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - nspConfigurationName - The name of the NSP Configuration. +// - options - NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.BeginReconcile +// method. +func (client *NetworkSecurityPerimeterConfigurationsClient) BeginReconcile(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*runtime.Poller[NetworkSecurityPerimeterConfigurationsClientReconcileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.reconcile(ctx, resourceGroupName, accountName, nspConfigurationName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[NetworkSecurityPerimeterConfigurationsClientReconcileResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[NetworkSecurityPerimeterConfigurationsClientReconcileResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Reconcile - Reconcile the NSP configuration for an account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +func (client *NetworkSecurityPerimeterConfigurationsClient) reconcile(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*http.Response, error) { + var err error + const operationName = "NetworkSecurityPerimeterConfigurationsClient.BeginReconcile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.reconcileCreateRequest(ctx, resourceGroupName, accountName, nspConfigurationName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// reconcileCreateRequest creates the Reconcile request. +func (client *NetworkSecurityPerimeterConfigurationsClient) reconcileCreateRequest(ctx context.Context, resourceGroupName string, accountName string, nspConfigurationName string, options *NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}/reconcile" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if nspConfigurationName == "" { + return nil, errors.New("parameter nspConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{nspConfigurationName}", url.PathEscape(nspConfigurationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client_example_test.go new file mode 100644 index 000000000000..01b97f333a22 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/networksecurityperimeterconfigurations_client_example_test.go @@ -0,0 +1,183 @@ +//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 armcognitiveservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListNetworkSecurityPerimeterConfigurations.json +func ExampleNetworkSecurityPerimeterConfigurationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNetworkSecurityPerimeterConfigurationsClient().NewListPager("resourceGroupName", "accountName", 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.NetworkSecurityPerimeterConfigurationList = armcognitiveservices.NetworkSecurityPerimeterConfigurationList{ + // Value: []*armcognitiveservices.NetworkSecurityPerimeterConfiguration{ + // { + // Name: to.Ptr("networkSecurityPerimeterConfigurationName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/networkSecurityPerimeterConfigurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/networkSecurityPerimeterConfigurations"), + // Properties: &armcognitiveservices.NetworkSecurityPerimeterConfigurationProperties{ + // NetworkSecurityPerimeter: &armcognitiveservices.NetworkSecurityPerimeter{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.Network/networkSecurityPerimeters/perimeter"), + // Location: to.Ptr("East US"), + // PerimeterGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Profile: &armcognitiveservices.NetworkSecurityPerimeterProfileInfo{ + // Name: to.Ptr("profileName"), + // AccessRules: []*armcognitiveservices.NetworkSecurityPerimeterAccessRule{ + // { + // Name: to.Ptr("ruleName"), + // Properties: &armcognitiveservices.NetworkSecurityPerimeterAccessRuleProperties{ + // AddressPrefixes: []*string{ + // to.Ptr("148.0.0.0/8"), + // to.Ptr("152.4.6.0/24")}, + // Direction: to.Ptr(armcognitiveservices.NspAccessRuleDirectionInbound), + // }, + // }}, + // AccessRulesVersion: to.Ptr[int64](1), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceAssociation: &armcognitiveservices.NetworkSecurityPerimeterConfigurationAssociationInfo{ + // Name: to.Ptr("associationName"), + // AccessMode: to.Ptr("Enforced"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetNetworkSecurityPerimeterConfigurations.json +func ExampleNetworkSecurityPerimeterConfigurationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNetworkSecurityPerimeterConfigurationsClient().Get(ctx, "resourceGroupName", "accountName", "NSPConfigurationName", 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.NetworkSecurityPerimeterConfiguration = armcognitiveservices.NetworkSecurityPerimeterConfiguration{ + // Name: to.Ptr("networkSecurityPerimeterConfigurationName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/networkSecurityPerimeterConfigurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/networkSecurityPerimeterConfigurations"), + // Properties: &armcognitiveservices.NetworkSecurityPerimeterConfigurationProperties{ + // NetworkSecurityPerimeter: &armcognitiveservices.NetworkSecurityPerimeter{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.Network/networkSecurityPerimeters/perimeter"), + // Location: to.Ptr("East US"), + // PerimeterGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Profile: &armcognitiveservices.NetworkSecurityPerimeterProfileInfo{ + // Name: to.Ptr("profileName"), + // AccessRules: []*armcognitiveservices.NetworkSecurityPerimeterAccessRule{ + // { + // Name: to.Ptr("ruleName"), + // Properties: &armcognitiveservices.NetworkSecurityPerimeterAccessRuleProperties{ + // AddressPrefixes: []*string{ + // to.Ptr("148.0.0.0/8"), + // to.Ptr("152.4.6.0/24")}, + // Direction: to.Ptr(armcognitiveservices.NspAccessRuleDirectionInbound), + // }, + // }}, + // AccessRulesVersion: to.Ptr[int64](1), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceAssociation: &armcognitiveservices.NetworkSecurityPerimeterConfigurationAssociationInfo{ + // Name: to.Ptr("associationName"), + // AccessMode: to.Ptr("Enforced"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ReconcileNetworkSecurityPerimeterConfigurations.json +func ExampleNetworkSecurityPerimeterConfigurationsClient_BeginReconcile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewNetworkSecurityPerimeterConfigurationsClient().BeginReconcile(ctx, "resourceGroupName", "accountName", "NSPConfigurationName", 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.NetworkSecurityPerimeterConfiguration = armcognitiveservices.NetworkSecurityPerimeterConfiguration{ + // Name: to.Ptr("networkSecurityPerimeterConfigurationName"), + // Type: to.Ptr("Microsoft.CognitiveServices/accounts/networkSecurityPerimeterConfigurations"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/networkSecurityPerimeterConfigurations"), + // Properties: &armcognitiveservices.NetworkSecurityPerimeterConfigurationProperties{ + // NetworkSecurityPerimeter: &armcognitiveservices.NetworkSecurityPerimeter{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.Network/networkSecurityPerimeters/perimeter"), + // Location: to.Ptr("East US"), + // PerimeterGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Profile: &armcognitiveservices.NetworkSecurityPerimeterProfileInfo{ + // Name: to.Ptr("profileName"), + // AccessRules: []*armcognitiveservices.NetworkSecurityPerimeterAccessRule{ + // { + // Name: to.Ptr("ruleName"), + // Properties: &armcognitiveservices.NetworkSecurityPerimeterAccessRuleProperties{ + // AddressPrefixes: []*string{ + // to.Ptr("148.0.0.0/8"), + // to.Ptr("152.4.6.0/24")}, + // Direction: to.Ptr(armcognitiveservices.NspAccessRuleDirectionInbound), + // }, + // }}, + // AccessRulesVersion: to.Ptr[int64](1), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceAssociation: &armcognitiveservices.NetworkSecurityPerimeterConfigurationAssociationInfo{ + // Name: to.Ptr("associationName"), + // AccessMode: to.Ptr("Enforced"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go index c20be400284e..48be898d0103 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all the available Cognitive Services account operations. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - 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-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go index 635a8ecd5b91..114c3a029332 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/operations_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetOperations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetOperations.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/options.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/options.go index c76660ebc044..d309b9f6da96 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/options.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/options.go @@ -160,6 +160,28 @@ type CommitmentTiersClientListOptions struct { // placeholder for future optional parameters } +// DefenderForAISettingsClientCreateOrUpdateOptions contains the optional parameters for the DefenderForAISettingsClient.CreateOrUpdate +// method. +type DefenderForAISettingsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DefenderForAISettingsClientGetOptions contains the optional parameters for the DefenderForAISettingsClient.Get method. +type DefenderForAISettingsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DefenderForAISettingsClientListOptions contains the optional parameters for the DefenderForAISettingsClient.NewListPager +// method. +type DefenderForAISettingsClientListOptions struct { + // placeholder for future optional parameters +} + +// DefenderForAISettingsClientUpdateOptions contains the optional parameters for the DefenderForAISettingsClient.Update method. +type DefenderForAISettingsClientUpdateOptions struct { + // placeholder for future optional parameters +} + // DeletedAccountsClientBeginPurgeOptions contains the optional parameters for the DeletedAccountsClient.BeginPurge method. type DeletedAccountsClientBeginPurgeOptions struct { // Resumes the LRO from the provided token. @@ -189,6 +211,12 @@ type DeploymentsClientBeginDeleteOptions struct { ResumeToken string } +// DeploymentsClientBeginUpdateOptions contains the optional parameters for the DeploymentsClient.BeginUpdate method. +type DeploymentsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. type DeploymentsClientGetOptions struct { // placeholder for future optional parameters @@ -199,6 +227,45 @@ type DeploymentsClientListOptions struct { // placeholder for future optional parameters } +// DeploymentsClientListSKUsOptions contains the optional parameters for the DeploymentsClient.NewListSKUsPager method. +type DeploymentsClientListSKUsOptions struct { + // placeholder for future optional parameters +} + +// EncryptionScopesClientBeginDeleteOptions contains the optional parameters for the EncryptionScopesClient.BeginDelete method. +type EncryptionScopesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// EncryptionScopesClientCreateOrUpdateOptions contains the optional parameters for the EncryptionScopesClient.CreateOrUpdate +// method. +type EncryptionScopesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// EncryptionScopesClientGetOptions contains the optional parameters for the EncryptionScopesClient.Get method. +type EncryptionScopesClientGetOptions struct { + // placeholder for future optional parameters +} + +// EncryptionScopesClientListOptions contains the optional parameters for the EncryptionScopesClient.NewListPager method. +type EncryptionScopesClientListOptions struct { + // placeholder for future optional parameters +} + +// LocationBasedModelCapacitiesClientListOptions contains the optional parameters for the LocationBasedModelCapacitiesClient.NewListPager +// method. +type LocationBasedModelCapacitiesClientListOptions struct { + // placeholder for future optional parameters +} + +// ManagementClientCalculateModelCapacityOptions contains the optional parameters for the ManagementClient.CalculateModelCapacity +// method. +type ManagementClientCalculateModelCapacityOptions struct { + // placeholder for future optional parameters +} + // ManagementClientCheckDomainAvailabilityOptions contains the optional parameters for the ManagementClient.CheckDomainAvailability // method. type ManagementClientCheckDomainAvailabilityOptions struct { @@ -211,11 +278,35 @@ type ManagementClientCheckSKUAvailabilityOptions struct { // placeholder for future optional parameters } +// ModelCapacitiesClientListOptions contains the optional parameters for the ModelCapacitiesClient.NewListPager method. +type ModelCapacitiesClientListOptions struct { + // placeholder for future optional parameters +} + // ModelsClientListOptions contains the optional parameters for the ModelsClient.NewListPager method. type ModelsClientListOptions struct { // placeholder for future optional parameters } +// NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.BeginReconcile +// method. +type NetworkSecurityPerimeterConfigurationsClientBeginReconcileOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// NetworkSecurityPerimeterConfigurationsClientGetOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.Get +// method. +type NetworkSecurityPerimeterConfigurationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// NetworkSecurityPerimeterConfigurationsClientListOptions contains the optional parameters for the NetworkSecurityPerimeterConfigurationsClient.NewListPager +// method. +type NetworkSecurityPerimeterConfigurationsClientListOptions struct { + // placeholder for future optional parameters +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters @@ -252,6 +343,92 @@ type PrivateLinkResourcesClientListOptions struct { // placeholder for future optional parameters } +// RaiBlocklistItemsClientBatchAddOptions contains the optional parameters for the RaiBlocklistItemsClient.BatchAdd method. +type RaiBlocklistItemsClientBatchAddOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistItemsClientBatchDeleteOptions contains the optional parameters for the RaiBlocklistItemsClient.BatchDelete +// method. +type RaiBlocklistItemsClientBatchDeleteOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistItemsClientBeginDeleteOptions contains the optional parameters for the RaiBlocklistItemsClient.BeginDelete +// method. +type RaiBlocklistItemsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RaiBlocklistItemsClientCreateOrUpdateOptions contains the optional parameters for the RaiBlocklistItemsClient.CreateOrUpdate +// method. +type RaiBlocklistItemsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistItemsClientGetOptions contains the optional parameters for the RaiBlocklistItemsClient.Get method. +type RaiBlocklistItemsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistItemsClientListOptions contains the optional parameters for the RaiBlocklistItemsClient.NewListPager method. +type RaiBlocklistItemsClientListOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistsClientBeginDeleteOptions contains the optional parameters for the RaiBlocklistsClient.BeginDelete method. +type RaiBlocklistsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RaiBlocklistsClientCreateOrUpdateOptions contains the optional parameters for the RaiBlocklistsClient.CreateOrUpdate method. +type RaiBlocklistsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistsClientGetOptions contains the optional parameters for the RaiBlocklistsClient.Get method. +type RaiBlocklistsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RaiBlocklistsClientListOptions contains the optional parameters for the RaiBlocklistsClient.NewListPager method. +type RaiBlocklistsClientListOptions struct { + // placeholder for future optional parameters +} + +// RaiContentFiltersClientGetOptions contains the optional parameters for the RaiContentFiltersClient.Get method. +type RaiContentFiltersClientGetOptions struct { + // placeholder for future optional parameters +} + +// RaiContentFiltersClientListOptions contains the optional parameters for the RaiContentFiltersClient.NewListPager method. +type RaiContentFiltersClientListOptions struct { + // placeholder for future optional parameters +} + +// RaiPoliciesClientBeginDeleteOptions contains the optional parameters for the RaiPoliciesClient.BeginDelete method. +type RaiPoliciesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RaiPoliciesClientCreateOrUpdateOptions contains the optional parameters for the RaiPoliciesClient.CreateOrUpdate method. +type RaiPoliciesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// RaiPoliciesClientGetOptions contains the optional parameters for the RaiPoliciesClient.Get method. +type RaiPoliciesClientGetOptions struct { + // placeholder for future optional parameters +} + +// RaiPoliciesClientListOptions contains the optional parameters for the RaiPoliciesClient.NewListPager method. +type RaiPoliciesClientListOptions struct { + // placeholder for future optional parameters +} + // ResourceSKUsClientListOptions contains the optional parameters for the ResourceSKUsClient.NewListPager method. type ResourceSKUsClientListOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go index 8e4b997298b9..e26bedfd82e1 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client.go @@ -47,7 +47,7 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Cognitive Services Account @@ -74,7 +74,7 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. // CreateOrUpdate - Update the state of specified private endpoint connection associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginCreateOrUpdate" @@ -120,7 +120,7 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, properties); err != nil { @@ -132,7 +132,7 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx // BeginDelete - Deletes the specified private endpoint connection associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Cognitive Services Account @@ -158,7 +158,7 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Delete - Deletes the specified private endpoint connection associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginDelete" @@ -204,7 +204,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -213,7 +213,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Gets the specified private endpoint connection associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - privateEndpointConnectionName - The name of the private endpoint connection associated with the Cognitive Services Account @@ -265,7 +265,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -283,7 +283,7 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // List - Gets the private endpoint connections associated with the Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.List @@ -330,7 +330,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go index 889e91fa38a0..05c817596757 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privateendpointconnections_client_example_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListPrivateEndpointConnections.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListPrivateEndpointConnections.json func ExamplePrivateEndpointConnectionsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -56,7 +56,7 @@ func ExamplePrivateEndpointConnectionsClient_List() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetPrivateEndpointConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetPrivateEndpointConnection.json func ExamplePrivateEndpointConnectionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -91,7 +91,7 @@ func ExamplePrivateEndpointConnectionsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/PutPrivateEndpointConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutPrivateEndpointConnection.json func ExamplePrivateEndpointConnectionsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -137,7 +137,7 @@ func ExamplePrivateEndpointConnectionsClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/DeletePrivateEndpointConnection.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeletePrivateEndpointConnection.json func ExamplePrivateEndpointConnectionsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go index 2cb99f9cde64..0284f57a3840 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client.go @@ -46,7 +46,7 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // List - Gets the private link resources that need to be created for a Cognitive Services account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - accountName - The name of Cognitive Services account. // - options - PrivateLinkResourcesClientListOptions contains the optional parameters for the PrivateLinkResourcesClient.List @@ -93,7 +93,7 @@ func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go index 3e5948db7604..f56f9da4f9a0 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/privatelinkresources_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListPrivateLinkResources.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListPrivateLinkResources.json func ExamplePrivateLinkResourcesClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client.go new file mode 100644 index 000000000000..add242331be6 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client.go @@ -0,0 +1,492 @@ +//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 armcognitiveservices + +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" +) + +// RaiBlocklistItemsClient contains the methods for the RaiBlocklistItems group. +// Don't use this type directly, use NewRaiBlocklistItemsClient() instead. +type RaiBlocklistItemsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRaiBlocklistItemsClient creates a new instance of RaiBlocklistItemsClient 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 NewRaiBlocklistItemsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RaiBlocklistItemsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RaiBlocklistItemsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BatchAdd - Batch operation to add blocklist items. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - raiBlocklistItems - Properties describing the custom blocklist items. +// - options - RaiBlocklistItemsClientBatchAddOptions contains the optional parameters for the RaiBlocklistItemsClient.BatchAdd +// method. +func (client *RaiBlocklistItemsClient) BatchAdd(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItems []*RaiBlocklistItemBulkRequest, options *RaiBlocklistItemsClientBatchAddOptions) (RaiBlocklistItemsClientBatchAddResponse, error) { + var err error + const operationName = "RaiBlocklistItemsClient.BatchAdd" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.batchAddCreateRequest(ctx, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItems, options) + if err != nil { + return RaiBlocklistItemsClientBatchAddResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiBlocklistItemsClientBatchAddResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RaiBlocklistItemsClientBatchAddResponse{}, err + } + resp, err := client.batchAddHandleResponse(httpResp) + return resp, err +} + +// batchAddCreateRequest creates the BatchAdd request. +func (client *RaiBlocklistItemsClient) batchAddCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItems []*RaiBlocklistItemBulkRequest, options *RaiBlocklistItemsClientBatchAddOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/addRaiBlocklistItems" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, raiBlocklistItems); err != nil { + return nil, err + } + return req, nil +} + +// batchAddHandleResponse handles the BatchAdd response. +func (client *RaiBlocklistItemsClient) batchAddHandleResponse(resp *http.Response) (RaiBlocklistItemsClientBatchAddResponse, error) { + result := RaiBlocklistItemsClientBatchAddResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlocklist); err != nil { + return RaiBlocklistItemsClientBatchAddResponse{}, err + } + return result, nil +} + +// BatchDelete - Batch operation to delete blocklist items. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - raiBlocklistItemsNames - List of RAI Blocklist Items Names. +// - options - RaiBlocklistItemsClientBatchDeleteOptions contains the optional parameters for the RaiBlocklistItemsClient.BatchDelete +// method. +func (client *RaiBlocklistItemsClient) BatchDelete(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemsNames any, options *RaiBlocklistItemsClientBatchDeleteOptions) (RaiBlocklistItemsClientBatchDeleteResponse, error) { + var err error + const operationName = "RaiBlocklistItemsClient.BatchDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.batchDeleteCreateRequest(ctx, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemsNames, options) + if err != nil { + return RaiBlocklistItemsClientBatchDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiBlocklistItemsClientBatchDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return RaiBlocklistItemsClientBatchDeleteResponse{}, err + } + return RaiBlocklistItemsClientBatchDeleteResponse{}, nil +} + +// batchDeleteCreateRequest creates the BatchDelete request. +func (client *RaiBlocklistItemsClient) batchDeleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemsNames any, options *RaiBlocklistItemsClientBatchDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/deleteRaiBlocklistItems" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, raiBlocklistItemsNames); err != nil { + return nil, err + } + return req, nil +} + +// CreateOrUpdate - Update the state of specified blocklist item associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - raiBlocklistItemName - The name of the RaiBlocklist Item associated with the custom blocklist +// - raiBlocklistItem - Properties describing the custom blocklist. +// - options - RaiBlocklistItemsClientCreateOrUpdateOptions contains the optional parameters for the RaiBlocklistItemsClient.CreateOrUpdate +// method. +func (client *RaiBlocklistItemsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, raiBlocklistItem RaiBlocklistItem, options *RaiBlocklistItemsClientCreateOrUpdateOptions) (RaiBlocklistItemsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "RaiBlocklistItemsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName, raiBlocklistItem, options) + if err != nil { + return RaiBlocklistItemsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiBlocklistItemsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return RaiBlocklistItemsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RaiBlocklistItemsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, raiBlocklistItem RaiBlocklistItem, options *RaiBlocklistItemsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + if raiBlocklistItemName == "" { + return nil, errors.New("parameter raiBlocklistItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistItemName}", url.PathEscape(raiBlocklistItemName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, raiBlocklistItem); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *RaiBlocklistItemsClient) createOrUpdateHandleResponse(resp *http.Response) (RaiBlocklistItemsClientCreateOrUpdateResponse, error) { + result := RaiBlocklistItemsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlocklistItem); err != nil { + return RaiBlocklistItemsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes the specified blocklist Item associated with the custom blocklist. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - raiBlocklistItemName - The name of the RaiBlocklist Item associated with the custom blocklist +// - options - RaiBlocklistItemsClientBeginDeleteOptions contains the optional parameters for the RaiBlocklistItemsClient.BeginDelete +// method. +func (client *RaiBlocklistItemsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *RaiBlocklistItemsClientBeginDeleteOptions) (*runtime.Poller[RaiBlocklistItemsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, raiBlocklistName, raiBlocklistItemName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RaiBlocklistItemsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RaiBlocklistItemsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the specified blocklist Item associated with the custom blocklist. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +func (client *RaiBlocklistItemsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *RaiBlocklistItemsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "RaiBlocklistItemsClient.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, accountName, raiBlocklistName, raiBlocklistItemName, 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 *RaiBlocklistItemsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *RaiBlocklistItemsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + if raiBlocklistItemName == "" { + return nil, errors.New("parameter raiBlocklistItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistItemName}", url.PathEscape(raiBlocklistItemName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the specified custom blocklist Item associated with the custom blocklist. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - raiBlocklistItemName - The name of the RaiBlocklist Item associated with the custom blocklist +// - options - RaiBlocklistItemsClientGetOptions contains the optional parameters for the RaiBlocklistItemsClient.Get method. +func (client *RaiBlocklistItemsClient) Get(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *RaiBlocklistItemsClientGetOptions) (RaiBlocklistItemsClientGetResponse, error) { + var err error + const operationName = "RaiBlocklistItemsClient.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, accountName, raiBlocklistName, raiBlocklistItemName, options) + if err != nil { + return RaiBlocklistItemsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiBlocklistItemsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RaiBlocklistItemsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RaiBlocklistItemsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string, options *RaiBlocklistItemsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + if raiBlocklistItemName == "" { + return nil, errors.New("parameter raiBlocklistItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistItemName}", url.PathEscape(raiBlocklistItemName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RaiBlocklistItemsClient) getHandleResponse(resp *http.Response) (RaiBlocklistItemsClientGetResponse, error) { + result := RaiBlocklistItemsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlocklistItem); err != nil { + return RaiBlocklistItemsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the blocklist items associated with the custom blocklist. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - options - RaiBlocklistItemsClientListOptions contains the optional parameters for the RaiBlocklistItemsClient.NewListPager +// method. +func (client *RaiBlocklistItemsClient) NewListPager(resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistItemsClientListOptions) *runtime.Pager[RaiBlocklistItemsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RaiBlocklistItemsClientListResponse]{ + More: func(page RaiBlocklistItemsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RaiBlocklistItemsClientListResponse) (RaiBlocklistItemsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RaiBlocklistItemsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, raiBlocklistName, options) + }, nil) + if err != nil { + return RaiBlocklistItemsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *RaiBlocklistItemsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistItemsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RaiBlocklistItemsClient) listHandleResponse(resp *http.Response) (RaiBlocklistItemsClientListResponse, error) { + result := RaiBlocklistItemsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlockListItemsResult); err != nil { + return RaiBlocklistItemsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client_example_test.go new file mode 100644 index 000000000000..1ac098f8629a --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklistitems_client_example_test.go @@ -0,0 +1,206 @@ +//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 armcognitiveservices_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/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListBlocklistItems.json +func ExampleRaiBlocklistItemsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRaiBlocklistItemsClient().NewListPager("resourceGroupName", "accountName", "raiBlocklistName", 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.RaiBlockListItemsResult = armcognitiveservices.RaiBlockListItemsResult{ + // Value: []*armcognitiveservices.RaiBlocklistItem{ + // { + // Name: to.Ptr("raiBlocklistItemName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName/raiBlocklistItems/raiBlocklistItemName"), + // Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + // IsRegex: to.Ptr(false), + // Pattern: to.Ptr("Pattern To Block"), + // }, + // }, + // { + // Name: to.Ptr("raiBlocklistItemName2"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName/raiBlocklistItems/raiBlocklistItemName2"), + // Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + // IsRegex: to.Ptr(false), + // Pattern: to.Ptr("Another Pattern To Block"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklistItem.json +func ExampleRaiBlocklistItemsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiBlocklistItemsClient().Get(ctx, "resourceGroupName", "accountName", "raiBlocklistName", "raiBlocklistItemName", 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.RaiBlocklistItem = armcognitiveservices.RaiBlocklistItem{ + // Name: to.Ptr("raiBlocklistItemName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName/raiBlocklistItems/raiBlocklistItemName"), + // Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + // IsRegex: to.Ptr(false), + // Pattern: to.Ptr("Pattern To Block"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklistItem.json +func ExampleRaiBlocklistItemsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiBlocklistItemsClient().CreateOrUpdate(ctx, "resourceGroupName", "accountName", "raiBlocklistName", "raiBlocklistItemName", armcognitiveservices.RaiBlocklistItem{ + Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + IsRegex: to.Ptr(false), + Pattern: to.Ptr("Pattern To Block"), + }, + }, 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.RaiBlocklistItem = armcognitiveservices.RaiBlocklistItem{ + // Name: to.Ptr("raiBlocklistItemName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName/raiBlocklistItems/raiBlocklistItemName"), + // Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + // IsRegex: to.Ptr(false), + // Pattern: to.Ptr("Pattern To Block"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklistItem.json +func ExampleRaiBlocklistItemsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRaiBlocklistItemsClient().BeginDelete(ctx, "resourceGroupName", "accountName", "raiBlocklistName", "raiBlocklistItemName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/AddRaiBlocklistItems.json +func ExampleRaiBlocklistItemsClient_BatchAdd() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiBlocklistItemsClient().BatchAdd(ctx, "resourceGroupName", "accountName", "myblocklist", []*armcognitiveservices.RaiBlocklistItemBulkRequest{ + { + Name: to.Ptr("myblocklistitem1"), + Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + IsRegex: to.Ptr(true), + Pattern: to.Ptr("^[a-z0-9_-]{2,16}$"), + }, + }, + { + Name: to.Ptr("myblocklistitem2"), + Properties: &armcognitiveservices.RaiBlocklistItemProperties{ + IsRegex: to.Ptr(false), + Pattern: to.Ptr("blockwords"), + }, + }}, 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.RaiBlocklist = armcognitiveservices.RaiBlocklist{ + // Name: to.Ptr("myblocklist"), + // Etag: to.Ptr("\"00000000-0000-0000-0000-000000000000\""), + // Properties: &armcognitiveservices.RaiBlocklistProperties{ + // Description: to.Ptr("Brief description of the blocklist"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklistItems.json +func ExampleRaiBlocklistItemsClient_BatchDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewRaiBlocklistItemsClient().BatchDelete(ctx, "resourceGroupName", "accountName", "raiBlocklistName", []any{ + "myblocklistitem1", + "myblocklistitem2", + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client.go new file mode 100644 index 000000000000..89a321d90468 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client.go @@ -0,0 +1,333 @@ +//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 armcognitiveservices + +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" +) + +// RaiBlocklistsClient contains the methods for the RaiBlocklists group. +// Don't use this type directly, use NewRaiBlocklistsClient() instead. +type RaiBlocklistsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRaiBlocklistsClient creates a new instance of RaiBlocklistsClient 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 NewRaiBlocklistsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RaiBlocklistsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RaiBlocklistsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Update the state of specified blocklist associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - raiBlocklist - Properties describing the custom blocklist. +// - options - RaiBlocklistsClientCreateOrUpdateOptions contains the optional parameters for the RaiBlocklistsClient.CreateOrUpdate +// method. +func (client *RaiBlocklistsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklist RaiBlocklist, options *RaiBlocklistsClientCreateOrUpdateOptions) (RaiBlocklistsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "RaiBlocklistsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, raiBlocklistName, raiBlocklist, options) + if err != nil { + return RaiBlocklistsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiBlocklistsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return RaiBlocklistsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RaiBlocklistsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklist RaiBlocklist, options *RaiBlocklistsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, raiBlocklist); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *RaiBlocklistsClient) createOrUpdateHandleResponse(resp *http.Response) (RaiBlocklistsClientCreateOrUpdateResponse, error) { + result := RaiBlocklistsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlocklist); err != nil { + return RaiBlocklistsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes the specified custom blocklist associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - options - RaiBlocklistsClientBeginDeleteOptions contains the optional parameters for the RaiBlocklistsClient.BeginDelete +// method. +func (client *RaiBlocklistsClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistsClientBeginDeleteOptions) (*runtime.Poller[RaiBlocklistsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, raiBlocklistName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RaiBlocklistsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RaiBlocklistsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the specified custom blocklist associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +func (client *RaiBlocklistsClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "RaiBlocklistsClient.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, accountName, raiBlocklistName, 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 *RaiBlocklistsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the specified custom blocklist associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiBlocklistName - The name of the RaiBlocklist associated with the Cognitive Services Account +// - options - RaiBlocklistsClientGetOptions contains the optional parameters for the RaiBlocklistsClient.Get method. +func (client *RaiBlocklistsClient) Get(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistsClientGetOptions) (RaiBlocklistsClientGetResponse, error) { + var err error + const operationName = "RaiBlocklistsClient.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, accountName, raiBlocklistName, options) + if err != nil { + return RaiBlocklistsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiBlocklistsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RaiBlocklistsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RaiBlocklistsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiBlocklistName string, options *RaiBlocklistsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiBlocklistName == "" { + return nil, errors.New("parameter raiBlocklistName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiBlocklistName}", url.PathEscape(raiBlocklistName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RaiBlocklistsClient) getHandleResponse(resp *http.Response) (RaiBlocklistsClientGetResponse, error) { + result := RaiBlocklistsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlocklist); err != nil { + return RaiBlocklistsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the custom blocklists associated with the Azure OpenAI account. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - options - RaiBlocklistsClientListOptions contains the optional parameters for the RaiBlocklistsClient.NewListPager method. +func (client *RaiBlocklistsClient) NewListPager(resourceGroupName string, accountName string, options *RaiBlocklistsClientListOptions) *runtime.Pager[RaiBlocklistsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RaiBlocklistsClientListResponse]{ + More: func(page RaiBlocklistsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RaiBlocklistsClientListResponse) (RaiBlocklistsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RaiBlocklistsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, nil) + if err != nil { + return RaiBlocklistsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *RaiBlocklistsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *RaiBlocklistsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RaiBlocklistsClient) listHandleResponse(resp *http.Response) (RaiBlocklistsClientListResponse, error) { + result := RaiBlocklistsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiBlockListResult); err != nil { + return RaiBlocklistsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client_example_test.go new file mode 100644 index 000000000000..8b86d0c43ec5 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raiblocklists_client_example_test.go @@ -0,0 +1,133 @@ +//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 armcognitiveservices_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/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListBlocklists.json +func ExampleRaiBlocklistsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRaiBlocklistsClient().NewListPager("resourceGroupName", "accountName", 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.RaiBlockListResult = armcognitiveservices.RaiBlockListResult{ + // Value: []*armcognitiveservices.RaiBlocklist{ + // { + // Name: to.Ptr("raiBlocklistName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName"), + // Properties: &armcognitiveservices.RaiBlocklistProperties{ + // Description: to.Ptr("This is a sample blocklist"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklist.json +func ExampleRaiBlocklistsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiBlocklistsClient().Get(ctx, "resourceGroupName", "accountName", "raiBlocklistName", 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.RaiBlocklist = armcognitiveservices.RaiBlocklist{ + // Name: to.Ptr("raiBlocklistName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName"), + // Properties: &armcognitiveservices.RaiBlocklistProperties{ + // Description: to.Ptr("This is a sample blocklist"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklist.json +func ExampleRaiBlocklistsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiBlocklistsClient().CreateOrUpdate(ctx, "resourceGroupName", "accountName", "raiBlocklistName", armcognitiveservices.RaiBlocklist{ + Properties: &armcognitiveservices.RaiBlocklistProperties{ + Description: to.Ptr("Basic blocklist description"), + }, + }, 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.RaiBlocklist = armcognitiveservices.RaiBlocklist{ + // Name: to.Ptr("raiBlocklistName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiBlocklists/raiBlocklistName"), + // Properties: &armcognitiveservices.RaiBlocklistProperties{ + // Description: to.Ptr("Basic blocklist description"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklist.json +func ExampleRaiBlocklistsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRaiBlocklistsClient().BeginDelete(ctx, "resourceGroupName", "accountName", "raiBlocklistName", 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/cognitiveservices/armcognitiveservices/raicontentfilters_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client.go new file mode 100644 index 000000000000..b6e74785613e --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client.go @@ -0,0 +1,168 @@ +//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 armcognitiveservices + +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" +) + +// RaiContentFiltersClient contains the methods for the RaiContentFilters group. +// Don't use this type directly, use NewRaiContentFiltersClient() instead. +type RaiContentFiltersClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRaiContentFiltersClient creates a new instance of RaiContentFiltersClient 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 NewRaiContentFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RaiContentFiltersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RaiContentFiltersClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get Content Filters by Name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - location - Resource location. +// - filterName - The name of the RAI Content Filter. +// - options - RaiContentFiltersClientGetOptions contains the optional parameters for the RaiContentFiltersClient.Get method. +func (client *RaiContentFiltersClient) Get(ctx context.Context, location string, filterName string, options *RaiContentFiltersClientGetOptions) (RaiContentFiltersClientGetResponse, error) { + var err error + const operationName = "RaiContentFiltersClient.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, location, filterName, options) + if err != nil { + return RaiContentFiltersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiContentFiltersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RaiContentFiltersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RaiContentFiltersClient) getCreateRequest(ctx context.Context, location string, filterName string, options *RaiContentFiltersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if filterName == "" { + return nil, errors.New("parameter filterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{filterName}", url.PathEscape(filterName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RaiContentFiltersClient) getHandleResponse(resp *http.Response) (RaiContentFiltersClientGetResponse, error) { + result := RaiContentFiltersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiContentFilter); err != nil { + return RaiContentFiltersClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List Content Filters types. +// +// Generated from API version 2024-10-01 +// - location - Resource location. +// - options - RaiContentFiltersClientListOptions contains the optional parameters for the RaiContentFiltersClient.NewListPager +// method. +func (client *RaiContentFiltersClient) NewListPager(location string, options *RaiContentFiltersClientListOptions) *runtime.Pager[RaiContentFiltersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RaiContentFiltersClientListResponse]{ + More: func(page RaiContentFiltersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RaiContentFiltersClientListResponse) (RaiContentFiltersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RaiContentFiltersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, location, options) + }, nil) + if err != nil { + return RaiContentFiltersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *RaiContentFiltersClient) listCreateRequest(ctx context.Context, location string, options *RaiContentFiltersClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RaiContentFiltersClient) listHandleResponse(resp *http.Response) (RaiContentFiltersClientListResponse, error) { + result := RaiContentFiltersClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiContentFilterListResult); err != nil { + return RaiContentFiltersClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client_example_test.go new file mode 100644 index 000000000000..be5c981c914d --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raicontentfilters_client_example_test.go @@ -0,0 +1,161 @@ +//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 armcognitiveservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListRaiContentFilters.json +func ExampleRaiContentFiltersClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRaiContentFiltersClient().NewListPager("WestUS", 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.RaiContentFilterListResult = armcognitiveservices.RaiContentFilterListResult{ + // Value: []*armcognitiveservices.RaiContentFilter{ + // { + // Name: to.Ptr("Hate"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/Hate"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Hate"), + // IsMultiLevelFilter: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("Sexual"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/Sexual"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Sexual"), + // IsMultiLevelFilter: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("Violence"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/Violence"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Violence"), + // IsMultiLevelFilter: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("Selfharm"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/Selfharm"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Selfharm"), + // IsMultiLevelFilter: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("Jailbreak"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/Jailbreak"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Jailbreak"), + // IsMultiLevelFilter: to.Ptr(false), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // }, + // { + // Name: to.Ptr("ProtectedMaterialText"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/ProtectedMaterialText"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Protected Material Text"), + // IsMultiLevelFilter: to.Ptr(false), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // }, + // { + // Name: to.Ptr("ProtectedMaterialCode"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/ProtectedMaterialCode"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Protected Material Code"), + // IsMultiLevelFilter: to.Ptr(false), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // }, + // { + // Name: to.Ptr("Profanity"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/Profanity"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Profanity"), + // IsMultiLevelFilter: to.Ptr(false), + // }, + // }, + // { + // Name: to.Ptr("IndirectAttack"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/IndirectAttack"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Indirect Attack"), + // IsMultiLevelFilter: to.Ptr(false), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiContentFilter.json +func ExampleRaiContentFiltersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiContentFiltersClient().Get(ctx, "WestUS", "IndirectAttack", 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.RaiContentFilter = armcognitiveservices.RaiContentFilter{ + // Name: to.Ptr("IndirectAttack"), + // Type: to.Ptr("Microsoft.CognitiveServices/locations/raiContentFilters"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CognitiveServices/locations/WestUS/raiContentFilters/IndirectAttack"), + // Properties: &armcognitiveservices.RaiContentFilterProperties{ + // Name: to.Ptr("Indirect Attack"), + // IsMultiLevelFilter: to.Ptr(false), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // } +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client.go new file mode 100644 index 000000000000..5655ab83c98b --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client.go @@ -0,0 +1,332 @@ +//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 armcognitiveservices + +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" +) + +// RaiPoliciesClient contains the methods for the RaiPolicies group. +// Don't use this type directly, use NewRaiPoliciesClient() instead. +type RaiPoliciesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRaiPoliciesClient creates a new instance of RaiPoliciesClient 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 NewRaiPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RaiPoliciesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RaiPoliciesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Update the state of specified Content Filters associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiPolicyName - The name of the RaiPolicy associated with the Cognitive Services Account +// - raiPolicy - Properties describing the Content Filters. +// - options - RaiPoliciesClientCreateOrUpdateOptions contains the optional parameters for the RaiPoliciesClient.CreateOrUpdate +// method. +func (client *RaiPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, raiPolicy RaiPolicy, options *RaiPoliciesClientCreateOrUpdateOptions) (RaiPoliciesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "RaiPoliciesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, raiPolicyName, raiPolicy, options) + if err != nil { + return RaiPoliciesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiPoliciesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return RaiPoliciesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RaiPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, raiPolicy RaiPolicy, options *RaiPoliciesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiPolicyName == "" { + return nil, errors.New("parameter raiPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiPolicyName}", url.PathEscape(raiPolicyName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, raiPolicy); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *RaiPoliciesClient) createOrUpdateHandleResponse(resp *http.Response) (RaiPoliciesClientCreateOrUpdateResponse, error) { + result := RaiPoliciesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiPolicy); err != nil { + return RaiPoliciesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes the specified Content Filters associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiPolicyName - The name of the RaiPolicy associated with the Cognitive Services Account +// - options - RaiPoliciesClientBeginDeleteOptions contains the optional parameters for the RaiPoliciesClient.BeginDelete method. +func (client *RaiPoliciesClient) BeginDelete(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *RaiPoliciesClientBeginDeleteOptions) (*runtime.Poller[RaiPoliciesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, accountName, raiPolicyName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RaiPoliciesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[RaiPoliciesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the specified Content Filters associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +func (client *RaiPoliciesClient) deleteOperation(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *RaiPoliciesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "RaiPoliciesClient.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, accountName, raiPolicyName, 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 *RaiPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *RaiPoliciesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiPolicyName == "" { + return nil, errors.New("parameter raiPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiPolicyName}", url.PathEscape(raiPolicyName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the specified Content Filters associated with the Azure OpenAI account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - raiPolicyName - The name of the RaiPolicy associated with the Cognitive Services Account +// - options - RaiPoliciesClientGetOptions contains the optional parameters for the RaiPoliciesClient.Get method. +func (client *RaiPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *RaiPoliciesClientGetOptions) (RaiPoliciesClientGetResponse, error) { + var err error + const operationName = "RaiPoliciesClient.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, accountName, raiPolicyName, options) + if err != nil { + return RaiPoliciesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RaiPoliciesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RaiPoliciesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RaiPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, raiPolicyName string, options *RaiPoliciesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if raiPolicyName == "" { + return nil, errors.New("parameter raiPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{raiPolicyName}", url.PathEscape(raiPolicyName)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RaiPoliciesClient) getHandleResponse(resp *http.Response) (RaiPoliciesClientGetResponse, error) { + result := RaiPoliciesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiPolicy); err != nil { + return RaiPoliciesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the content filters associated with the Azure OpenAI account. +// +// Generated from API version 2024-10-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - accountName - The name of Cognitive Services account. +// - options - RaiPoliciesClientListOptions contains the optional parameters for the RaiPoliciesClient.NewListPager method. +func (client *RaiPoliciesClient) NewListPager(resourceGroupName string, accountName string, options *RaiPoliciesClientListOptions) *runtime.Pager[RaiPoliciesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RaiPoliciesClientListResponse]{ + More: func(page RaiPoliciesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RaiPoliciesClientListResponse) (RaiPoliciesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RaiPoliciesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, nil) + if err != nil { + return RaiPoliciesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *RaiPoliciesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *RaiPoliciesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-10-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RaiPoliciesClient) listHandleResponse(resp *http.Response) (RaiPoliciesClientListResponse, error) { + result := RaiPoliciesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RaiPolicyListResult); err != nil { + return RaiPoliciesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client_example_test.go new file mode 100644 index 000000000000..657042e7f6d2 --- /dev/null +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/raipolicies_client_example_test.go @@ -0,0 +1,461 @@ +//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 armcognitiveservices_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/cognitiveservices/armcognitiveservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListRaiPolicies.json +func ExampleRaiPoliciesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRaiPoliciesClient().NewListPager("resourceGroupName", "accountName", 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.RaiPolicyListResult = armcognitiveservices.RaiPolicyListResult{ + // Value: []*armcognitiveservices.RaiPolicy{ + // { + // Name: to.Ptr("raiPolicyName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiPolicies/raiPolicyName"), + // Properties: &armcognitiveservices.RaiPolicyProperties{ + // BasePolicyName: to.Ptr("Microsoft.Default"), + // ContentFilters: []*armcognitiveservices.RaiPolicyContentFilter{ + // { + // Name: to.Ptr("Hate"), + // Blocking: to.Ptr(false), + // Enabled: to.Ptr(false), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Hate"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Sexual"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Sexual"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Selfharm"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Selfharm"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Violence"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Violence"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Jailbreak"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Protected Material Text"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Protected Material Code"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Profanity"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }}, + // Mode: to.Ptr(armcognitiveservices.RaiPolicyModeAsynchronousFilter), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiPolicy.json +func ExampleRaiPoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiPoliciesClient().Get(ctx, "resourceGroupName", "accountName", "raiPolicyName", 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.RaiPolicy = armcognitiveservices.RaiPolicy{ + // Name: to.Ptr("raiPolicyName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiPolicies/raiPolicyName"), + // Properties: &armcognitiveservices.RaiPolicyProperties{ + // BasePolicyName: to.Ptr("Microsoft.Default"), + // ContentFilters: []*armcognitiveservices.RaiPolicyContentFilter{ + // { + // Name: to.Ptr("Hate"), + // Blocking: to.Ptr(false), + // Enabled: to.Ptr(false), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Hate"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Sexual"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Sexual"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Selfharm"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Selfharm"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Violence"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Violence"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Jailbreak"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Protected Material Text"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Protected Material Code"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Profanity"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }}, + // Mode: to.Ptr(armcognitiveservices.RaiPolicyModeAsynchronousFilter), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiPolicy.json +func ExampleRaiPoliciesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRaiPoliciesClient().CreateOrUpdate(ctx, "resourceGroupName", "accountName", "raiPolicyName", armcognitiveservices.RaiPolicy{ + Properties: &armcognitiveservices.RaiPolicyProperties{ + BasePolicyName: to.Ptr("Microsoft.Default"), + ContentFilters: []*armcognitiveservices.RaiPolicyContentFilter{ + { + Name: to.Ptr("Hate"), + Blocking: to.Ptr(false), + Enabled: to.Ptr(false), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + }, + { + Name: to.Ptr("Hate"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + }, + { + Name: to.Ptr("Sexual"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + }, + { + Name: to.Ptr("Sexual"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + }, + { + Name: to.Ptr("Selfharm"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + }, + { + Name: to.Ptr("Selfharm"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + }, + { + Name: to.Ptr("Violence"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + }, + { + Name: to.Ptr("Violence"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + }, + { + Name: to.Ptr("Jailbreak"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + }, + { + Name: to.Ptr("Protected Material Text"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + }, + { + Name: to.Ptr("Protected Material Code"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + }, + { + Name: to.Ptr("Profanity"), + Blocking: to.Ptr(true), + Enabled: to.Ptr(true), + Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + }}, + Mode: to.Ptr(armcognitiveservices.RaiPolicyModeAsynchronousFilter), + }, + }, 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.RaiPolicy = armcognitiveservices.RaiPolicy{ + // Name: to.Ptr("raiPolicyName"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/raiPolicies/raiPolicyName"), + // Properties: &armcognitiveservices.RaiPolicyProperties{ + // BasePolicyName: to.Ptr("Microsoft.Default"), + // ContentFilters: []*armcognitiveservices.RaiPolicyContentFilter{ + // { + // Name: to.Ptr("Hate"), + // Blocking: to.Ptr(false), + // Enabled: to.Ptr(false), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Hate"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Sexual"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Sexual"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Selfharm"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelHigh), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Selfharm"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Violence"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Violence"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // SeverityThreshold: to.Ptr(armcognitiveservices.ContentLevelMedium), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Jailbreak"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }, + // { + // Name: to.Ptr("Protected Material Text"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Protected Material Code"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourceCompletion), + // }, + // { + // Name: to.Ptr("Profanity"), + // Blocking: to.Ptr(true), + // Enabled: to.Ptr(true), + // Source: to.Ptr(armcognitiveservices.RaiPolicyContentSourcePrompt), + // }}, + // Mode: to.Ptr(armcognitiveservices.RaiPolicyModeAsynchronousFilter), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiPolicy.json +func ExampleRaiPoliciesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcognitiveservices.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRaiPoliciesClient().BeginDelete(ctx, "resourceGroupName", "accountName", "raiPolicyName", 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/cognitiveservices/armcognitiveservices/resourceskus_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go index 78a95040acaa..bc5b832ca0f5 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client.go @@ -45,7 +45,7 @@ func NewResourceSKUsClient(subscriptionID string, credential azcore.TokenCredent // NewListPager - Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - options - ResourceSKUsClientListOptions contains the optional parameters for the ResourceSKUsClient.NewListPager method. func (client *ResourceSKUsClient) NewListPager(options *ResourceSKUsClientListOptions) *runtime.Pager[ResourceSKUsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceSKUsClientListResponse]{ @@ -82,7 +82,7 @@ func (client *ResourceSKUsClient) listCreateRequest(ctx context.Context, options return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go index a0e3bb471a19..6635171a1511 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/resourceskus_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/GetSkus.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSkus.json func ExampleResourceSKUsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/response_types.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/responses.go similarity index 59% rename from sdk/resourcemanager/cognitiveservices/armcognitiveservices/response_types.go rename to sdk/resourcemanager/cognitiveservices/armcognitiveservices/responses.go index bbfb22564c1f..2f41b58b7ec3 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/response_types.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/responses.go @@ -160,6 +160,30 @@ type CommitmentTiersClientListResponse struct { CommitmentTierListResult } +// DefenderForAISettingsClientCreateOrUpdateResponse contains the response from method DefenderForAISettingsClient.CreateOrUpdate. +type DefenderForAISettingsClientCreateOrUpdateResponse struct { + // The Defender for AI resource. + DefenderForAISetting +} + +// DefenderForAISettingsClientGetResponse contains the response from method DefenderForAISettingsClient.Get. +type DefenderForAISettingsClientGetResponse struct { + // The Defender for AI resource. + DefenderForAISetting +} + +// DefenderForAISettingsClientListResponse contains the response from method DefenderForAISettingsClient.NewListPager. +type DefenderForAISettingsClientListResponse struct { + // The list of cognitive services Defender for AI Settings. + DefenderForAISettingResult +} + +// DefenderForAISettingsClientUpdateResponse contains the response from method DefenderForAISettingsClient.Update. +type DefenderForAISettingsClientUpdateResponse struct { + // The Defender for AI resource. + DefenderForAISetting +} + // DeletedAccountsClientGetResponse contains the response from method DeletedAccountsClient.Get. type DeletedAccountsClientGetResponse struct { // Cognitive Services account is an Azure resource representing the provisioned account, it's type, location and SKU. @@ -200,6 +224,53 @@ type DeploymentsClientListResponse struct { DeploymentListResult } +// DeploymentsClientListSKUsResponse contains the response from method DeploymentsClient.NewListSKUsPager. +type DeploymentsClientListSKUsResponse struct { + // The list of cognitive services accounts operation response. + DeploymentSKUListResult +} + +// DeploymentsClientUpdateResponse contains the response from method DeploymentsClient.BeginUpdate. +type DeploymentsClientUpdateResponse struct { + // Cognitive Services account deployment. + Deployment +} + +// EncryptionScopesClientCreateOrUpdateResponse contains the response from method EncryptionScopesClient.CreateOrUpdate. +type EncryptionScopesClientCreateOrUpdateResponse struct { + // Cognitive Services EncryptionScope + EncryptionScope +} + +// EncryptionScopesClientDeleteResponse contains the response from method EncryptionScopesClient.BeginDelete. +type EncryptionScopesClientDeleteResponse struct { + // placeholder for future response values +} + +// EncryptionScopesClientGetResponse contains the response from method EncryptionScopesClient.Get. +type EncryptionScopesClientGetResponse struct { + // Cognitive Services EncryptionScope + EncryptionScope +} + +// EncryptionScopesClientListResponse contains the response from method EncryptionScopesClient.NewListPager. +type EncryptionScopesClientListResponse struct { + // The list of cognitive services EncryptionScopes. + EncryptionScopeListResult +} + +// LocationBasedModelCapacitiesClientListResponse contains the response from method LocationBasedModelCapacitiesClient.NewListPager. +type LocationBasedModelCapacitiesClientListResponse struct { + // The list of cognitive services accounts operation response. + ModelCapacityListResult +} + +// ManagementClientCalculateModelCapacityResponse contains the response from method ManagementClient.CalculateModelCapacity. +type ManagementClientCalculateModelCapacityResponse struct { + // Calculate Model Capacity result. + CalculateModelCapacityResult +} + // ManagementClientCheckDomainAvailabilityResponse contains the response from method ManagementClient.CheckDomainAvailability. type ManagementClientCheckDomainAvailabilityResponse struct { // Domain availability. @@ -212,12 +283,36 @@ type ManagementClientCheckSKUAvailabilityResponse struct { SKUAvailabilityListResult } +// ModelCapacitiesClientListResponse contains the response from method ModelCapacitiesClient.NewListPager. +type ModelCapacitiesClientListResponse struct { + // The list of cognitive services accounts operation response. + ModelCapacityListResult +} + // ModelsClientListResponse contains the response from method ModelsClient.NewListPager. type ModelsClientListResponse struct { // The list of cognitive services models. ModelListResult } +// NetworkSecurityPerimeterConfigurationsClientGetResponse contains the response from method NetworkSecurityPerimeterConfigurationsClient.Get. +type NetworkSecurityPerimeterConfigurationsClientGetResponse struct { + // NSP Configuration for an Cognitive Services account. + NetworkSecurityPerimeterConfiguration +} + +// NetworkSecurityPerimeterConfigurationsClientListResponse contains the response from method NetworkSecurityPerimeterConfigurationsClient.NewListPager. +type NetworkSecurityPerimeterConfigurationsClientListResponse struct { + // A list of NSP configurations for an Cognitive Services account. + NetworkSecurityPerimeterConfigurationList +} + +// NetworkSecurityPerimeterConfigurationsClientReconcileResponse contains the response from method NetworkSecurityPerimeterConfigurationsClient.BeginReconcile. +type NetworkSecurityPerimeterConfigurationsClientReconcileResponse struct { + // NSP Configuration for an Cognitive Services account. + NetworkSecurityPerimeterConfiguration +} + // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. @@ -253,6 +348,98 @@ type PrivateLinkResourcesClientListResponse struct { PrivateLinkResourceListResult } +// RaiBlocklistItemsClientBatchAddResponse contains the response from method RaiBlocklistItemsClient.BatchAdd. +type RaiBlocklistItemsClientBatchAddResponse struct { + // Cognitive Services RaiBlocklist. + RaiBlocklist +} + +// RaiBlocklistItemsClientBatchDeleteResponse contains the response from method RaiBlocklistItemsClient.BatchDelete. +type RaiBlocklistItemsClientBatchDeleteResponse struct { + // placeholder for future response values +} + +// RaiBlocklistItemsClientCreateOrUpdateResponse contains the response from method RaiBlocklistItemsClient.CreateOrUpdate. +type RaiBlocklistItemsClientCreateOrUpdateResponse struct { + // Cognitive Services RaiBlocklist Item. + RaiBlocklistItem +} + +// RaiBlocklistItemsClientDeleteResponse contains the response from method RaiBlocklistItemsClient.BeginDelete. +type RaiBlocklistItemsClientDeleteResponse struct { + // placeholder for future response values +} + +// RaiBlocklistItemsClientGetResponse contains the response from method RaiBlocklistItemsClient.Get. +type RaiBlocklistItemsClientGetResponse struct { + // Cognitive Services RaiBlocklist Item. + RaiBlocklistItem +} + +// RaiBlocklistItemsClientListResponse contains the response from method RaiBlocklistItemsClient.NewListPager. +type RaiBlocklistItemsClientListResponse struct { + // The list of cognitive services RAI Blocklist Items. + RaiBlockListItemsResult +} + +// RaiBlocklistsClientCreateOrUpdateResponse contains the response from method RaiBlocklistsClient.CreateOrUpdate. +type RaiBlocklistsClientCreateOrUpdateResponse struct { + // Cognitive Services RaiBlocklist. + RaiBlocklist +} + +// RaiBlocklistsClientDeleteResponse contains the response from method RaiBlocklistsClient.BeginDelete. +type RaiBlocklistsClientDeleteResponse struct { + // placeholder for future response values +} + +// RaiBlocklistsClientGetResponse contains the response from method RaiBlocklistsClient.Get. +type RaiBlocklistsClientGetResponse struct { + // Cognitive Services RaiBlocklist. + RaiBlocklist +} + +// RaiBlocklistsClientListResponse contains the response from method RaiBlocklistsClient.NewListPager. +type RaiBlocklistsClientListResponse struct { + // The list of cognitive services RAI Blocklists. + RaiBlockListResult +} + +// RaiContentFiltersClientGetResponse contains the response from method RaiContentFiltersClient.Get. +type RaiContentFiltersClientGetResponse struct { + // Azure OpenAI Content Filter. + RaiContentFilter +} + +// RaiContentFiltersClientListResponse contains the response from method RaiContentFiltersClient.NewListPager. +type RaiContentFiltersClientListResponse struct { + // The list of Content Filters. + RaiContentFilterListResult +} + +// RaiPoliciesClientCreateOrUpdateResponse contains the response from method RaiPoliciesClient.CreateOrUpdate. +type RaiPoliciesClientCreateOrUpdateResponse struct { + // Cognitive Services RaiPolicy. + RaiPolicy +} + +// RaiPoliciesClientDeleteResponse contains the response from method RaiPoliciesClient.BeginDelete. +type RaiPoliciesClientDeleteResponse struct { + // placeholder for future response values +} + +// RaiPoliciesClientGetResponse contains the response from method RaiPoliciesClient.Get. +type RaiPoliciesClientGetResponse struct { + // Cognitive Services RaiPolicy. + RaiPolicy +} + +// RaiPoliciesClientListResponse contains the response from method RaiPoliciesClient.NewListPager. +type RaiPoliciesClientListResponse struct { + // The list of cognitive services RaiPolicies. + RaiPolicyListResult +} + // ResourceSKUsClientListResponse contains the response from method ResourceSKUsClient.NewListPager. type ResourceSKUsClientListResponse struct { // The Get Skus operation response. diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/time_rfc3339.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/time_rfc3339.go index 8e31b6f3b72f..9024c258fe32 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/time_rfc3339.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/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/cognitiveservices/armcognitiveservices/usages_client.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client.go index 429bc67df156..efc7a4dbbe8a 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client.go @@ -45,7 +45,7 @@ func NewUsagesClient(subscriptionID string, credential azcore.TokenCredential, o // NewListPager - Get usages for the requested subscription // -// Generated from API version 2023-05-01 +// Generated from API version 2024-10-01 // - location - Resource location. // - options - UsagesClientListOptions contains the optional parameters for the UsagesClient.NewListPager method. func (client *UsagesClient) NewListPager(location string, options *UsagesClientListOptions) *runtime.Pager[UsagesClientListResponse] { @@ -87,10 +87,10 @@ func (client *UsagesClient) listCreateRequest(ctx context.Context, location stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2024-10-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client_example_test.go b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client_example_test.go index 8c52dec67481..5e94b2140a95 100644 --- a/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client_example_test.go +++ b/sdk/resourcemanager/cognitiveservices/armcognitiveservices/usages_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/310a0100f5b020c1900c527a6aa70d21992f078a/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2023-05-01/examples/ListUsages.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/069a65e8a6d1a6c0c58d9a9d97610b7103b6e8a5/specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListUsages.json func ExampleUsagesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil {