diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_metadata.json b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_metadata.json index fe5b35770b24..48bfad73d07d 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_metadata.json +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/_metadata.json @@ -1,11 +1,6 @@ { - "commit": "b2965096067d6f8374b5485b0568fd36e7c9d099", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.41.3", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/cognitiveservices/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.41.3 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/cognitiveservices/resource-manager/readme.md" + "apiVersion": "2025-10-01-preview", + "apiVersions": { + "Microsoft.CognitiveServices": "2025-10-01-preview" + } } \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/apiview-properties.json b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/apiview-properties.json index 1263563adda4..034929beb3ed 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/apiview-properties.json +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/apiview-properties.json @@ -1,431 +1,565 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "Microsoft.CognitiveServices", "CrossLanguageDefinitionId": { - "azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2": null, - "azure.mgmt.cognitiveservices.models.AADAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.AbusePenalty": null, - "azure.mgmt.cognitiveservices.models.AccessKeyAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.Resource": null, - "azure.mgmt.cognitiveservices.models.AzureEntityResource": null, - "azure.mgmt.cognitiveservices.models.Account": null, - "azure.mgmt.cognitiveservices.models.AccountKeyAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.AccountListResult": null, - "azure.mgmt.cognitiveservices.models.DeploymentModel": null, - "azure.mgmt.cognitiveservices.models.AccountModel": null, - "azure.mgmt.cognitiveservices.models.AccountModelListResult": null, - "azure.mgmt.cognitiveservices.models.AccountProperties": null, - "azure.mgmt.cognitiveservices.models.AccountSku": null, - "azure.mgmt.cognitiveservices.models.AccountSkuListResult": null, - "azure.mgmt.cognitiveservices.models.ApiKeyAuthConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.ApiKeys": null, - "azure.mgmt.cognitiveservices.models.ApiProperties": null, - "azure.mgmt.cognitiveservices.models.BillingMeterInfo": null, - "azure.mgmt.cognitiveservices.models.CalculateModelCapacityParameter": null, - "azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult": null, - "azure.mgmt.cognitiveservices.models.CalculateModelCapacityResultEstimatedCapacity": null, - "azure.mgmt.cognitiveservices.models.CallRateLimit": null, - "azure.mgmt.cognitiveservices.models.ProxyResource": null, - "azure.mgmt.cognitiveservices.models.CapabilityHost": null, - "azure.mgmt.cognitiveservices.models.ResourceBase": null, - "azure.mgmt.cognitiveservices.models.CapabilityHostProperties": null, - "azure.mgmt.cognitiveservices.models.CapacityConfig": null, - "azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityParameter": null, - "azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityParameter": null, - "azure.mgmt.cognitiveservices.models.CommitmentCost": null, - "azure.mgmt.cognitiveservices.models.CommitmentPeriod": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlan": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociationListResult": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlanAssociation": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlanListResult": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlanProperties": null, - "azure.mgmt.cognitiveservices.models.CommitmentQuota": null, - "azure.mgmt.cognitiveservices.models.CommitmentTier": null, - "azure.mgmt.cognitiveservices.models.CommitmentTierListResult": null, - "azure.mgmt.cognitiveservices.models.ConnectionAccessKey": null, - "azure.mgmt.cognitiveservices.models.ConnectionAccountKey": null, - "azure.mgmt.cognitiveservices.models.ConnectionApiKey": null, - "azure.mgmt.cognitiveservices.models.ConnectionManagedIdentity": null, - "azure.mgmt.cognitiveservices.models.ConnectionOAuth2": null, - "azure.mgmt.cognitiveservices.models.ConnectionPersonalAccessToken": null, - "azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource": null, - "azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResourceArmPaginatedResult": null, - "azure.mgmt.cognitiveservices.models.ConnectionServicePrincipal": null, - "azure.mgmt.cognitiveservices.models.ConnectionSharedAccessSignature": null, - "azure.mgmt.cognitiveservices.models.ConnectionUpdateContent": null, - "azure.mgmt.cognitiveservices.models.ConnectionUsernamePassword": null, - "azure.mgmt.cognitiveservices.models.RaiBlocklistConfig": null, - "azure.mgmt.cognitiveservices.models.CustomBlocklistConfig": null, - "azure.mgmt.cognitiveservices.models.CustomKeys": null, - "azure.mgmt.cognitiveservices.models.CustomKeysConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.RaiTopicConfig": null, - "azure.mgmt.cognitiveservices.models.CustomTopicConfig": null, - "azure.mgmt.cognitiveservices.models.DefenderForAISetting": null, - "azure.mgmt.cognitiveservices.models.DefenderForAISettingResult": null, - "azure.mgmt.cognitiveservices.models.Deployment": null, - "azure.mgmt.cognitiveservices.models.DeploymentCapacitySettings": null, - "azure.mgmt.cognitiveservices.models.DeploymentListResult": null, - "azure.mgmt.cognitiveservices.models.DeploymentProperties": null, - "azure.mgmt.cognitiveservices.models.DeploymentScaleSettings": null, - "azure.mgmt.cognitiveservices.models.DeploymentSkuListResult": null, - "azure.mgmt.cognitiveservices.models.DomainAvailability": null, - "azure.mgmt.cognitiveservices.models.Encryption": null, - "azure.mgmt.cognitiveservices.models.EncryptionScope": null, - "azure.mgmt.cognitiveservices.models.EncryptionScopeListResult": null, - "azure.mgmt.cognitiveservices.models.EncryptionScopeProperties": null, - "azure.mgmt.cognitiveservices.models.ErrorAdditionalInfo": null, - "azure.mgmt.cognitiveservices.models.ErrorDetail": null, - "azure.mgmt.cognitiveservices.models.ErrorDetailAutoGenerated": null, - "azure.mgmt.cognitiveservices.models.ErrorResponse": null, - "azure.mgmt.cognitiveservices.models.ErrorResponseAutoGenerated": null, - "azure.mgmt.cognitiveservices.models.Identity": null, - "azure.mgmt.cognitiveservices.models.IpRule": null, - "azure.mgmt.cognitiveservices.models.KeyVaultProperties": null, - "azure.mgmt.cognitiveservices.models.ManagedIdentityAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.MetricName": null, - "azure.mgmt.cognitiveservices.models.Model": null, - "azure.mgmt.cognitiveservices.models.ModelCapacityCalculatorWorkload": null, - "azure.mgmt.cognitiveservices.models.ModelCapacityCalculatorWorkloadRequestParam": null, - "azure.mgmt.cognitiveservices.models.ModelCapacityListResult": null, - "azure.mgmt.cognitiveservices.models.ModelCapacityListResultValueItem": null, - "azure.mgmt.cognitiveservices.models.ModelDeprecationInfo": null, - "azure.mgmt.cognitiveservices.models.ModelListResult": null, - "azure.mgmt.cognitiveservices.models.ModelSku": null, - "azure.mgmt.cognitiveservices.models.ModelSkuCapacityProperties": null, - "azure.mgmt.cognitiveservices.models.MultiRegionSettings": null, - "azure.mgmt.cognitiveservices.models.NetworkInjection": null, - "azure.mgmt.cognitiveservices.models.NetworkRuleSet": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeter": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRule": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRuleProperties": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationAssociationInfo": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationList": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationProperties": null, - "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterProfileInfo": null, - "azure.mgmt.cognitiveservices.models.NoneAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.OAuth2AuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.Operation": null, - "azure.mgmt.cognitiveservices.models.OperationDisplay": null, - "azure.mgmt.cognitiveservices.models.OperationListResult": null, - "azure.mgmt.cognitiveservices.models.PATAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.PatchResourceTags": null, - "azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku": null, - "azure.mgmt.cognitiveservices.models.PrivateEndpoint": null, - "azure.mgmt.cognitiveservices.models.PrivateEndpointConnection": null, - "azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionListResult": null, - "azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.PrivateLinkResource": null, - "azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult": null, - "azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties": null, - "azure.mgmt.cognitiveservices.models.PrivateLinkServiceConnectionState": null, - "azure.mgmt.cognitiveservices.models.Project": null, - "azure.mgmt.cognitiveservices.models.ProjectListResult": null, - "azure.mgmt.cognitiveservices.models.ProjectProperties": null, - "azure.mgmt.cognitiveservices.models.ProvisioningIssue": null, - "azure.mgmt.cognitiveservices.models.ProvisioningIssueProperties": null, - "azure.mgmt.cognitiveservices.models.QuotaLimit": null, - "azure.mgmt.cognitiveservices.models.QuotaTier": null, - "azure.mgmt.cognitiveservices.models.QuotaTierListResult": null, - "azure.mgmt.cognitiveservices.models.QuotaTierProperties": null, - "azure.mgmt.cognitiveservices.models.QuotaTierUpgradeEligibilityInfo": null, - "azure.mgmt.cognitiveservices.models.RaiBlocklist": null, - "azure.mgmt.cognitiveservices.models.RaiBlocklistItem": null, - "azure.mgmt.cognitiveservices.models.RaiBlocklistItemBulkRequest": null, - "azure.mgmt.cognitiveservices.models.RaiBlocklistItemProperties": null, - "azure.mgmt.cognitiveservices.models.RaiBlockListItemsResult": null, - "azure.mgmt.cognitiveservices.models.RaiBlocklistProperties": null, - "azure.mgmt.cognitiveservices.models.RaiBlockListResult": null, - "azure.mgmt.cognitiveservices.models.RaiContentFilter": null, - "azure.mgmt.cognitiveservices.models.RaiContentFilterListResult": null, - "azure.mgmt.cognitiveservices.models.RaiContentFilterProperties": null, - "azure.mgmt.cognitiveservices.models.RaiMonitorConfig": null, - "azure.mgmt.cognitiveservices.models.RaiPolicy": null, - "azure.mgmt.cognitiveservices.models.RaiPolicyContentFilter": null, - "azure.mgmt.cognitiveservices.models.RaiPolicyListResult": null, - "azure.mgmt.cognitiveservices.models.RaiPolicyProperties": null, - "azure.mgmt.cognitiveservices.models.RaiTopic": null, - "azure.mgmt.cognitiveservices.models.RaiTopicProperties": null, - "azure.mgmt.cognitiveservices.models.RaiTopicResult": null, - "azure.mgmt.cognitiveservices.models.RegenerateKeyParameters": null, - "azure.mgmt.cognitiveservices.models.RegionSetting": null, - "azure.mgmt.cognitiveservices.models.ReplacementConfig": null, - "azure.mgmt.cognitiveservices.models.RequestMatchPattern": null, - "azure.mgmt.cognitiveservices.models.ResourceSku": null, - "azure.mgmt.cognitiveservices.models.ResourceSkuListResult": null, - "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo": null, - "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions": null, - "azure.mgmt.cognitiveservices.models.SASAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.ServicePrincipalAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.Sku": null, - "azure.mgmt.cognitiveservices.models.SkuAvailability": null, - "azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult": null, - "azure.mgmt.cognitiveservices.models.SkuCapability": null, - "azure.mgmt.cognitiveservices.models.SkuChangeInfo": null, - "azure.mgmt.cognitiveservices.models.SkuResource": null, - "azure.mgmt.cognitiveservices.models.SystemData": null, - "azure.mgmt.cognitiveservices.models.ThrottlingRule": null, - "azure.mgmt.cognitiveservices.models.Usage": null, - "azure.mgmt.cognitiveservices.models.UsageListResult": null, - "azure.mgmt.cognitiveservices.models.UserAssignedIdentity": null, - "azure.mgmt.cognitiveservices.models.UsernamePasswordAuthTypeConnectionProperties": null, - "azure.mgmt.cognitiveservices.models.UserOwnedAmlWorkspace": null, - "azure.mgmt.cognitiveservices.models.UserOwnedStorage": null, - "azure.mgmt.cognitiveservices.models.VirtualNetworkRule": null, - "azure.mgmt.cognitiveservices.models.CreatedByType": null, - "azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus": null, - "azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProvisioningState": null, - "azure.mgmt.cognitiveservices.models.ScenarioType": null, - "azure.mgmt.cognitiveservices.models.SkuTier": null, - "azure.mgmt.cognitiveservices.models.ResourceIdentityType": null, - "azure.mgmt.cognitiveservices.models.ProvisioningState": null, - "azure.mgmt.cognitiveservices.models.NetworkRuleAction": null, - "azure.mgmt.cognitiveservices.models.ByPassSelection": null, - "azure.mgmt.cognitiveservices.models.KeySource": null, - "azure.mgmt.cognitiveservices.models.PublicNetworkAccess": null, - "azure.mgmt.cognitiveservices.models.RoutingMethods": null, - "azure.mgmt.cognitiveservices.models.AbusePenaltyAction": null, - "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType": null, - "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode": null, - "azure.mgmt.cognitiveservices.models.UnitType": null, - "azure.mgmt.cognitiveservices.models.QuotaUsageStatus": null, - "azure.mgmt.cognitiveservices.models.DeprecationStatus": null, - "azure.mgmt.cognitiveservices.models.ModelLifecycleStatus": null, - "azure.mgmt.cognitiveservices.models.Origin": null, - "azure.mgmt.cognitiveservices.models.ActionType": null, - "azure.mgmt.cognitiveservices.models.HostingModel": null, - "azure.mgmt.cognitiveservices.models.DeploymentProvisioningState": null, - "azure.mgmt.cognitiveservices.models.DeploymentScaleType": null, - "azure.mgmt.cognitiveservices.models.DeploymentModelVersionUpgradeOption": null, - "azure.mgmt.cognitiveservices.models.CommitmentPlanProvisioningState": null, - "azure.mgmt.cognitiveservices.models.EncryptionScopeProvisioningState": null, - "azure.mgmt.cognitiveservices.models.EncryptionScopeState": null, - "azure.mgmt.cognitiveservices.models.ContentLevel": null, - "azure.mgmt.cognitiveservices.models.RaiPolicyContentSource": null, - "azure.mgmt.cognitiveservices.models.RaiPolicyType": null, - "azure.mgmt.cognitiveservices.models.RaiPolicyMode": null, - "azure.mgmt.cognitiveservices.models.NspAccessRuleDirection": null, - "azure.mgmt.cognitiveservices.models.DefenderForAISettingState": null, - "azure.mgmt.cognitiveservices.models.ConnectionAuthType": null, - "azure.mgmt.cognitiveservices.models.ConnectionCategory": null, - "azure.mgmt.cognitiveservices.models.ConnectionGroup": null, - "azure.mgmt.cognitiveservices.models.ManagedPERequirement": null, - "azure.mgmt.cognitiveservices.models.ManagedPEStatus": null, - "azure.mgmt.cognitiveservices.models.TierUpgradePolicy": null, - "azure.mgmt.cognitiveservices.models.UpgradeAvailabilityStatus": null, - "azure.mgmt.cognitiveservices.models.CapabilityHostKind": null, - "azure.mgmt.cognitiveservices.models.CapabilityHostProvisioningState": null, - "azure.mgmt.cognitiveservices.models.KeyName": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.begin_create": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.begin_create": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.begin_update": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.begin_update": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_by_resource_group": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_by_resource_group": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_keys": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_keys": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.regenerate_key": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.regenerate_key": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_skus": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_skus": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_usages": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_usages": null, - "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_models": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_models": null, - "azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations.begin_purge": null, - "azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations.begin_purge": null, - "azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.ResourceSkusOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.ResourceSkusOperations.list": null, - "azure.mgmt.cognitiveservices.operations.UsagesOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.UsagesOperations.list": null, - "azure.mgmt.cognitiveservices.operations.Operations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.Operations.list": null, - "azure.mgmt.cognitiveservices.CognitiveServicesManagementClient.check_sku_availability": null, - "azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient.check_sku_availability": null, - "azure.mgmt.cognitiveservices.CognitiveServicesManagementClient.check_domain_availability": null, - "azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient.check_domain_availability": null, - "azure.mgmt.cognitiveservices.CognitiveServicesManagementClient.calculate_model_capacity": null, - "azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient.calculate_model_capacity": null, - "azure.mgmt.cognitiveservices.operations.CommitmentTiersOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentTiersOperations.list": null, - "azure.mgmt.cognitiveservices.operations.ModelsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.ModelsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.LocationBasedModelCapacitiesOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.LocationBasedModelCapacitiesOperations.list": null, - "azure.mgmt.cognitiveservices.operations.ModelCapacitiesOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.ModelCapacitiesOperations.list": null, - "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.PrivateLinkResourcesOperations.list": null, - "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.begin_update": null, - "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.begin_update": null, - "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.list_skus": null, - "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.list_skus": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.get": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_create_or_update_plan": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_create_or_update_plan": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_update_plan": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_update_plan": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_delete_plan": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_delete_plan": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.get_plan": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.get_plan": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list_plans_by_resource_group": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list_plans_by_resource_group": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list_plans_by_subscription": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list_plans_by_subscription": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list_associations": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list_associations": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.get_association": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.get_association": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_create_or_update_association": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_create_or_update_association": null, - "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_delete_association": null, - "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_delete_association": null, - "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.list": null, - "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.get": null, - "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.list": null, - "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.get": null, - "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.batch_add": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.batch_add": null, - "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.batch_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.batch_delete": null, - "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.RaiContentFiltersOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiContentFiltersOperations.list": null, - "azure.mgmt.cognitiveservices.operations.RaiContentFiltersOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.RaiContentFiltersOperations.get": null, - "azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations.begin_reconcile": null, - "azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.begin_reconcile": null, - "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.update": null, - "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.update": null, - "azure.mgmt.cognitiveservices.operations.ProjectsOperations.begin_create": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.begin_create": null, - "azure.mgmt.cognitiveservices.operations.ProjectsOperations.begin_update": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.begin_update": null, - "azure.mgmt.cognitiveservices.operations.ProjectsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.ProjectsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.ProjectsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.delete": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.delete": null, - "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.update": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.update": null, - "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.create": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.create": null, - "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.delete": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.delete": null, - "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.update": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.update": null, - "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.create": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.create": null, - "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.list": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.list": null, - "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.begin_delete": null, - "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.get": null, - "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.begin_create_or_update": null, - "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.list_by_subscription": null, - "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.list_by_subscription": null, - "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.get": null, - "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.get": null, - "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.update": null, - "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.update": null, - "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.create_or_update": null, - "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.create_or_update": null + "azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2": "Microsoft.CognitiveServices.ConnectionPropertiesV2", + "azure.mgmt.cognitiveservices.models.AADAuthTypeConnectionProperties": "Microsoft.CognitiveServices.AADAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.AbusePenalty": "Microsoft.CognitiveServices.AbusePenalty", + "azure.mgmt.cognitiveservices.models.AccessKeyAuthTypeConnectionProperties": "Microsoft.CognitiveServices.AccessKeyAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.cognitiveservices.models.Account": "Microsoft.CognitiveServices.Account", + "azure.mgmt.cognitiveservices.models.AccountKeyAuthTypeConnectionProperties": "Microsoft.CognitiveServices.AccountKeyAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.DeploymentModel": "Microsoft.CognitiveServices.DeploymentModel", + "azure.mgmt.cognitiveservices.models.AccountModel": "Microsoft.CognitiveServices.AccountModel", + "azure.mgmt.cognitiveservices.models.AccountProperties": "Microsoft.CognitiveServices.AccountProperties", + "azure.mgmt.cognitiveservices.models.AccountSku": "Microsoft.CognitiveServices.AccountSku", + "azure.mgmt.cognitiveservices.models.AccountSkuListResult": "Microsoft.CognitiveServices.AccountSkuListResult", + "azure.mgmt.cognitiveservices.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.cognitiveservices.models.AgentApplication": "Microsoft.CognitiveServices.AgentApplication", + "azure.mgmt.cognitiveservices.models.AgentDeployment": "Microsoft.CognitiveServices.AgentDeployment", + "azure.mgmt.cognitiveservices.models.ResourceBase": "Microsoft.CognitiveServices.ResourceBase", + "azure.mgmt.cognitiveservices.models.AgentDeploymentProperties": "Microsoft.CognitiveServices.AgentDeploymentProperties", + "azure.mgmt.cognitiveservices.models.AgenticApplicationProperties": "Microsoft.CognitiveServices.AgenticApplicationProperties", + "azure.mgmt.cognitiveservices.models.AgentProtocolVersion": "Microsoft.CognitiveServices.AgentProtocolVersion", + "azure.mgmt.cognitiveservices.models.AgentReference": "Microsoft.CognitiveServices.AgentReference", + "azure.mgmt.cognitiveservices.models.AgentReferenceProperties": "Microsoft.CognitiveServices.AgentReferenceProperties", + "azure.mgmt.cognitiveservices.models.AgentReferenceResourceArmPaginatedResult": "Microsoft.CognitiveServices.AgentReferenceResourceArmPaginatedResult", + "azure.mgmt.cognitiveservices.models.ApiKeyAuthConnectionProperties": "Microsoft.CognitiveServices.ApiKeyAuthConnectionProperties", + "azure.mgmt.cognitiveservices.models.ApiKeys": "Microsoft.CognitiveServices.ApiKeys", + "azure.mgmt.cognitiveservices.models.ApiProperties": "Microsoft.CognitiveServices.ApiProperties", + "azure.mgmt.cognitiveservices.models.ApplicationAuthorizationPolicy": "Microsoft.CognitiveServices.ApplicationAuthorizationPolicy", + "azure.mgmt.cognitiveservices.models.ApplicationTrafficRoutingPolicy": "Microsoft.CognitiveServices.ApplicationTrafficRoutingPolicy", + "azure.mgmt.cognitiveservices.models.AssignedIdentity": "Microsoft.CognitiveServices.AssignedIdentity", + "azure.mgmt.cognitiveservices.models.BillingMeterInfo": "Microsoft.CognitiveServices.BillingMeterInfo", + "azure.mgmt.cognitiveservices.models.CalculateModelCapacityParameter": "Microsoft.CognitiveServices.CalculateModelCapacityParameter", + "azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult": "Microsoft.CognitiveServices.CalculateModelCapacityResult", + "azure.mgmt.cognitiveservices.models.CalculateModelCapacityResultEstimatedCapacity": "Microsoft.CognitiveServices.CalculateModelCapacityResultEstimatedCapacity", + "azure.mgmt.cognitiveservices.models.CallRateLimit": "Microsoft.CognitiveServices.CallRateLimit", + "azure.mgmt.cognitiveservices.models.CapabilityHost": "Microsoft.CognitiveServices.CapabilityHost", + "azure.mgmt.cognitiveservices.models.CapabilityHostProperties": "Microsoft.CognitiveServices.CapabilityHostProperties", + "azure.mgmt.cognitiveservices.models.CapacityConfig": "Microsoft.CognitiveServices.CapacityConfig", + "azure.mgmt.cognitiveservices.models.ChannelsBuiltInAuthorizationPolicy": "Microsoft.CognitiveServices.ChannelsBuiltInAuthorizationPolicy", + "azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityParameter": "Microsoft.CognitiveServices.CheckDomainAvailabilityParameter", + "azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityParameter": "Microsoft.CognitiveServices.CheckSkuAvailabilityParameter", + "azure.mgmt.cognitiveservices.models.CommitmentCost": "Microsoft.CognitiveServices.CommitmentCost", + "azure.mgmt.cognitiveservices.models.CommitmentPeriod": "Microsoft.CognitiveServices.CommitmentPeriod", + "azure.mgmt.cognitiveservices.models.CommitmentPlan": "Microsoft.CognitiveServices.CommitmentPlan", + "azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociation", + "azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociationProperties": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociationProperties", + "azure.mgmt.cognitiveservices.models.CommitmentPlanAssociation": "Microsoft.CognitiveServices.CommitmentPlanAssociation", + "azure.mgmt.cognitiveservices.models.CommitmentPlanProperties": "Microsoft.CognitiveServices.CommitmentPlanProperties", + "azure.mgmt.cognitiveservices.models.CommitmentQuota": "Microsoft.CognitiveServices.CommitmentQuota", + "azure.mgmt.cognitiveservices.models.CommitmentTier": "Microsoft.CognitiveServices.CommitmentTier", + "azure.mgmt.cognitiveservices.models.Compute": "Microsoft.CognitiveServices.Compute", + "azure.mgmt.cognitiveservices.models.ComputePatch": "Microsoft.CognitiveServices.ComputePatch", + "azure.mgmt.cognitiveservices.models.ComputeProperties": "Microsoft.CognitiveServices.ComputeProperties", + "azure.mgmt.cognitiveservices.models.ConnectionAccessKey": "Microsoft.CognitiveServices.ConnectionAccessKey", + "azure.mgmt.cognitiveservices.models.ConnectionAccountKey": "Microsoft.CognitiveServices.ConnectionAccountKey", + "azure.mgmt.cognitiveservices.models.ConnectionApiKey": "Microsoft.CognitiveServices.ConnectionApiKey", + "azure.mgmt.cognitiveservices.models.ConnectionManagedIdentity": "Microsoft.CognitiveServices.ConnectionManagedIdentity", + "azure.mgmt.cognitiveservices.models.ConnectionOAuth2": "Microsoft.CognitiveServices.ConnectionOAuth2", + "azure.mgmt.cognitiveservices.models.ConnectionPersonalAccessToken": "Microsoft.CognitiveServices.ConnectionPersonalAccessToken", + "azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResource", + "azure.mgmt.cognitiveservices.models.ConnectionServicePrincipal": "Microsoft.CognitiveServices.ConnectionServicePrincipal", + "azure.mgmt.cognitiveservices.models.ConnectionSharedAccessSignature": "Microsoft.CognitiveServices.ConnectionSharedAccessSignature", + "azure.mgmt.cognitiveservices.models.ConnectionUpdateContent": "Microsoft.CognitiveServices.ConnectionUpdateContent", + "azure.mgmt.cognitiveservices.models.ConnectionUsernamePassword": "Microsoft.CognitiveServices.ConnectionUsernamePassword", + "azure.mgmt.cognitiveservices.models.RaiBlocklistConfig": "Microsoft.CognitiveServices.RaiBlocklistConfig", + "azure.mgmt.cognitiveservices.models.CustomBlocklistConfig": "Microsoft.CognitiveServices.CustomBlocklistConfig", + "azure.mgmt.cognitiveservices.models.CustomKeys": "Microsoft.CognitiveServices.CustomKeys", + "azure.mgmt.cognitiveservices.models.CustomKeysConnectionProperties": "Microsoft.CognitiveServices.CustomKeysConnectionProperties", + "azure.mgmt.cognitiveservices.models.RaiTopicConfig": "Microsoft.CognitiveServices.RaiTopicConfig", + "azure.mgmt.cognitiveservices.models.CustomTopicConfig": "Microsoft.CognitiveServices.CustomTopicConfig", + "azure.mgmt.cognitiveservices.models.DefenderForAISetting": "Microsoft.CognitiveServices.DefenderForAISetting", + "azure.mgmt.cognitiveservices.models.DefenderForAISettingProperties": "Microsoft.CognitiveServices.DefenderForAISettingProperties", + "azure.mgmt.cognitiveservices.models.Deployment": "Microsoft.CognitiveServices.Deployment", + "azure.mgmt.cognitiveservices.models.DeploymentCapacitySettings": "Microsoft.CognitiveServices.DeploymentCapacitySettings", + "azure.mgmt.cognitiveservices.models.DeploymentProperties": "Microsoft.CognitiveServices.DeploymentProperties", + "azure.mgmt.cognitiveservices.models.DeploymentScaleSettings": "Microsoft.CognitiveServices.DeploymentScaleSettings", + "azure.mgmt.cognitiveservices.models.DomainAvailability": "Microsoft.CognitiveServices.DomainAvailability", + "azure.mgmt.cognitiveservices.models.Encryption": "Microsoft.CognitiveServices.Encryption", + "azure.mgmt.cognitiveservices.models.EncryptionScope": "Microsoft.CognitiveServices.EncryptionScope", + "azure.mgmt.cognitiveservices.models.EncryptionScopeProperties": "Microsoft.CognitiveServices.EncryptionScopeProperties", + "azure.mgmt.cognitiveservices.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.cognitiveservices.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.cognitiveservices.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.cognitiveservices.models.OutboundRule": "Microsoft.CognitiveServices.OutboundRule", + "azure.mgmt.cognitiveservices.models.FqdnOutboundRule": "Microsoft.CognitiveServices.FqdnOutboundRule", + "azure.mgmt.cognitiveservices.models.HostedAgentDeployment": "Microsoft.CognitiveServices.HostedAgentDeployment", + "azure.mgmt.cognitiveservices.models.Identity": "Microsoft.CognitiveServices.Identity", + "azure.mgmt.cognitiveservices.models.IpRule": "Microsoft.CognitiveServices.IpRule", + "azure.mgmt.cognitiveservices.models.KeyVaultProperties": "Microsoft.CognitiveServices.KeyVaultProperties", + "azure.mgmt.cognitiveservices.models.ManagedAgentDeployment": "Microsoft.CognitiveServices.ManagedAgentDeployment", + "azure.mgmt.cognitiveservices.models.ManagedIdentityAuthTypeConnectionProperties": "Microsoft.CognitiveServices.ManagedIdentityAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionOptions": "Microsoft.CognitiveServices.ManagedNetworkProvisionOptions", + "azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus": "Microsoft.CognitiveServices.ManagedNetworkProvisionStatus", + "azure.mgmt.cognitiveservices.models.ManagedNetworkSettings": "Microsoft.CognitiveServices.ManagedNetworkSettings", + "azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsBasicResource": "Microsoft.CognitiveServices.ManagedNetworkSettingsBasicResource", + "azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsEx": "Microsoft.CognitiveServices.ManagedNetworkSettingsEx", + "azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsProperties": "Microsoft.CognitiveServices.ManagedNetworkSettingsProperties", + "azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResource", + "azure.mgmt.cognitiveservices.models.MetricName": "Microsoft.CognitiveServices.MetricName", + "azure.mgmt.cognitiveservices.models.Model": "Microsoft.CognitiveServices.Model", + "azure.mgmt.cognitiveservices.models.ModelCapacityCalculatorWorkload": "Microsoft.CognitiveServices.ModelCapacityCalculatorWorkload", + "azure.mgmt.cognitiveservices.models.ModelCapacityCalculatorWorkloadRequestParam": "Microsoft.CognitiveServices.ModelCapacityCalculatorWorkloadRequestParam", + "azure.mgmt.cognitiveservices.models.ModelCapacityListResultValueItem": "Microsoft.CognitiveServices.ModelCapacityListResultValueItem", + "azure.mgmt.cognitiveservices.models.ModelDeprecationInfo": "Microsoft.CognitiveServices.ModelDeprecationInfo", + "azure.mgmt.cognitiveservices.models.ModelSku": "Microsoft.CognitiveServices.ModelSku", + "azure.mgmt.cognitiveservices.models.ModelSkuCapacityProperties": "Microsoft.CognitiveServices.ModelSkuCapacityProperties", + "azure.mgmt.cognitiveservices.models.MultiRegionSettings": "Microsoft.CognitiveServices.MultiRegionSettings", + "azure.mgmt.cognitiveservices.models.NetworkInjection": "Microsoft.CognitiveServices.NetworkInjection", + "azure.mgmt.cognitiveservices.models.NetworkRuleSet": "Microsoft.CognitiveServices.NetworkRuleSet", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeter": "Microsoft.CognitiveServices.NetworkSecurityPerimeter", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRule": "Microsoft.CognitiveServices.NetworkSecurityPerimeterAccessRule", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRuleProperties": "Microsoft.CognitiveServices.NetworkSecurityPerimeterAccessRuleProperties", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem": "Microsoft.CognitiveServices.NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfiguration", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationAssociationInfo": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurationAssociationInfo", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationProperties": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurationProperties", + "azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterProfileInfo": "Microsoft.CognitiveServices.NetworkSecurityPerimeterProfileInfo", + "azure.mgmt.cognitiveservices.models.NoneAuthTypeConnectionProperties": "Microsoft.CognitiveServices.NoneAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.OAuth2AuthTypeConnectionProperties": "Microsoft.CognitiveServices.OAuth2AuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.cognitiveservices.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.cognitiveservices.models.OrganizationSharedBuiltInAuthorizationPolicy": "Microsoft.CognitiveServices.OrganizationSharedBuiltInAuthorizationPolicy", + "azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource": "Microsoft.CognitiveServices.OutboundRuleBasicResource", + "azure.mgmt.cognitiveservices.models.OutboundRuleListResult": "Microsoft.CognitiveServices.OutboundRuleListResult", + "azure.mgmt.cognitiveservices.models.PATAuthTypeConnectionProperties": "Microsoft.CognitiveServices.PATAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.PatchResourceTags": "Microsoft.CognitiveServices.PatchResourceTags", + "azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku": "Microsoft.CognitiveServices.PatchResourceTagsAndSku", + "azure.mgmt.cognitiveservices.models.Pool": "Microsoft.CognitiveServices.Pool", + "azure.mgmt.cognitiveservices.models.PrivateEndpoint": "Azure.ResourceManager.CommonTypes.PrivateEndpoint", + "azure.mgmt.cognitiveservices.models.PrivateEndpointConnection": "Microsoft.CognitiveServices.PrivateEndpointConnection", + "azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionListResult": "Microsoft.CognitiveServices.PrivateEndpointConnectionListResult", + "azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties": "Microsoft.CognitiveServices.PrivateEndpointConnectionProperties", + "azure.mgmt.cognitiveservices.models.PrivateLinkResource": "Microsoft.CognitiveServices.PrivateLinkResource", + "azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult": "Microsoft.CognitiveServices.PrivateLinkResourceListResult", + "azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties": "Microsoft.CognitiveServices.PrivateLinkResourceProperties", + "azure.mgmt.cognitiveservices.models.PrivateLinkServiceConnectionState": "Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState", + "azure.mgmt.cognitiveservices.models.Project": "Microsoft.CognitiveServices.Project", + "azure.mgmt.cognitiveservices.models.ProjectCapabilityHost": "Microsoft.CognitiveServices.ProjectCapabilityHost", + "azure.mgmt.cognitiveservices.models.ProjectCapabilityHostProperties": "Microsoft.CognitiveServices.ProjectCapabilityHostProperties", + "azure.mgmt.cognitiveservices.models.ProjectProperties": "Microsoft.CognitiveServices.ProjectProperties", + "azure.mgmt.cognitiveservices.models.ProvisioningIssue": "Microsoft.CognitiveServices.ProvisioningIssue", + "azure.mgmt.cognitiveservices.models.ProvisioningIssueProperties": "Microsoft.CognitiveServices.ProvisioningIssueProperties", + "azure.mgmt.cognitiveservices.models.QuotaLimit": "Microsoft.CognitiveServices.QuotaLimit", + "azure.mgmt.cognitiveservices.models.QuotaTier": "Microsoft.CognitiveServices.QuotaTier", + "azure.mgmt.cognitiveservices.models.QuotaTierProperties": "Microsoft.CognitiveServices.QuotaTierProperties", + "azure.mgmt.cognitiveservices.models.QuotaTierUpgradeEligibilityInfo": "Microsoft.CognitiveServices.QuotaTierUpgradeEligibilityInfo", + "azure.mgmt.cognitiveservices.models.RaiBlocklist": "Microsoft.CognitiveServices.RaiBlocklist", + "azure.mgmt.cognitiveservices.models.RaiBlocklistItem": "Microsoft.CognitiveServices.RaiBlocklistItem", + "azure.mgmt.cognitiveservices.models.RaiBlocklistItemBulkRequest": "Microsoft.CognitiveServices.RaiBlocklistItemBulkRequest", + "azure.mgmt.cognitiveservices.models.RaiBlocklistItemProperties": "Microsoft.CognitiveServices.RaiBlocklistItemProperties", + "azure.mgmt.cognitiveservices.models.RaiBlocklistProperties": "Microsoft.CognitiveServices.RaiBlocklistProperties", + "azure.mgmt.cognitiveservices.models.RaiContentFilter": "Microsoft.CognitiveServices.RaiContentFilter", + "azure.mgmt.cognitiveservices.models.RaiContentFilterProperties": "Microsoft.CognitiveServices.RaiContentFilterProperties", + "azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider": "Microsoft.CognitiveServices.RaiExternalSafetyProvider", + "azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderProperties": "Microsoft.CognitiveServices.RaiExternalSafetyProviderProperties", + "azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchema", + "azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchemaProperties": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemaProperties", + "azure.mgmt.cognitiveservices.models.RaiMonitorConfig": "Microsoft.CognitiveServices.RaiMonitorConfig", + "azure.mgmt.cognitiveservices.models.RaiPolicy": "Microsoft.CognitiveServices.RaiPolicy", + "azure.mgmt.cognitiveservices.models.RaiPolicyContentFilter": "Microsoft.CognitiveServices.RaiPolicyContentFilter", + "azure.mgmt.cognitiveservices.models.RaiPolicyProperties": "Microsoft.CognitiveServices.RaiPolicyProperties", + "azure.mgmt.cognitiveservices.models.RaiSafetyProviderConfig": "Microsoft.CognitiveServices.RaiSafetyProviderConfig", + "azure.mgmt.cognitiveservices.models.RaiToolLabel": "Microsoft.CognitiveServices.RaiToolLabel", + "azure.mgmt.cognitiveservices.models.RaiToolLabelProperties": "Microsoft.CognitiveServices.RaiToolLabelProperties", + "azure.mgmt.cognitiveservices.models.RaiToolLabelPropertiesAccountScope": "Microsoft.CognitiveServices.RaiToolLabelPropertiesAccountScope", + "azure.mgmt.cognitiveservices.models.RaiToolLabelPropertiesProjectScopesItem": "Microsoft.CognitiveServices.RaiToolLabelPropertiesProjectScopesItem", + "azure.mgmt.cognitiveservices.models.RaiTopic": "Microsoft.CognitiveServices.RaiTopic", + "azure.mgmt.cognitiveservices.models.RaiTopicProperties": "Microsoft.CognitiveServices.RaiTopicProperties", + "azure.mgmt.cognitiveservices.models.RegenerateKeyParameters": "Microsoft.CognitiveServices.RegenerateKeyParameters", + "azure.mgmt.cognitiveservices.models.RegionSetting": "Microsoft.CognitiveServices.RegionSetting", + "azure.mgmt.cognitiveservices.models.ReplacementConfig": "Microsoft.CognitiveServices.ReplacementConfig", + "azure.mgmt.cognitiveservices.models.RequestMatchPattern": "Microsoft.CognitiveServices.RequestMatchPattern", + "azure.mgmt.cognitiveservices.models.ResourceSku": "Microsoft.CognitiveServices.ResourceSku", + "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo": "Microsoft.CognitiveServices.ResourceSkuRestrictionInfo", + "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions": "Microsoft.CognitiveServices.ResourceSkuRestrictions", + "azure.mgmt.cognitiveservices.models.RoleBasedBuiltInAuthorizationPolicy": "Microsoft.CognitiveServices.RoleBasedBuiltInAuthorizationPolicy", + "azure.mgmt.cognitiveservices.models.RootError": "Microsoft.CognitiveServices.RootError", + "azure.mgmt.cognitiveservices.models.SafetyProviderConfig": "Microsoft.CognitiveServices.SafetyProviderConfig", + "azure.mgmt.cognitiveservices.models.SASAuthTypeConnectionProperties": "Microsoft.CognitiveServices.SASAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.ServicePrincipalAuthTypeConnectionProperties": "Microsoft.CognitiveServices.ServicePrincipalAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.Sku": "Microsoft.CognitiveServices.Sku", + "azure.mgmt.cognitiveservices.models.SkuAvailability": "Microsoft.CognitiveServices.SkuAvailability", + "azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult": "Microsoft.CognitiveServices.SkuAvailabilityListResult", + "azure.mgmt.cognitiveservices.models.SkuCapability": "Microsoft.CognitiveServices.SkuCapability", + "azure.mgmt.cognitiveservices.models.SkuChangeInfo": "Microsoft.CognitiveServices.SkuChangeInfo", + "azure.mgmt.cognitiveservices.models.SkuResource": "Microsoft.CognitiveServices.SkuResource", + "azure.mgmt.cognitiveservices.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.cognitiveservices.models.ThrottlingRule": "Microsoft.CognitiveServices.ThrottlingRule", + "azure.mgmt.cognitiveservices.models.TrafficRoutingRule": "Microsoft.CognitiveServices.TrafficRoutingRule", + "azure.mgmt.cognitiveservices.models.Usage": "Microsoft.CognitiveServices.Usage", + "azure.mgmt.cognitiveservices.models.UsageListResult": "Microsoft.CognitiveServices.UsageListResult", + "azure.mgmt.cognitiveservices.models.UserAssignedIdentity": "Microsoft.CognitiveServices.UserAssignedIdentity", + "azure.mgmt.cognitiveservices.models.UsernamePasswordAuthTypeConnectionProperties": "Microsoft.CognitiveServices.UsernamePasswordAuthTypeConnectionProperties", + "azure.mgmt.cognitiveservices.models.UserOwnedAmlWorkspace": "Microsoft.CognitiveServices.UserOwnedAmlWorkspace", + "azure.mgmt.cognitiveservices.models.UserOwnedStorage": "Microsoft.CognitiveServices.UserOwnedStorage", + "azure.mgmt.cognitiveservices.models.VersionedAgentReference": "Microsoft.CognitiveServices.VersionedAgentReference", + "azure.mgmt.cognitiveservices.models.VirtualNetworkRule": "Microsoft.CognitiveServices.VirtualNetworkRule", + "azure.mgmt.cognitiveservices.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.cognitiveservices.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.cognitiveservices.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.cognitiveservices.models.ProvisioningState": "Microsoft.CognitiveServices.ProvisioningState", + "azure.mgmt.cognitiveservices.models.NetworkRuleAction": "Microsoft.CognitiveServices.NetworkRuleAction", + "azure.mgmt.cognitiveservices.models.ByPassSelection": "Microsoft.CognitiveServices.ByPassSelection", + "azure.mgmt.cognitiveservices.models.KeySource": "Microsoft.CognitiveServices.KeySource", + "azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus": "Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProvisioningState": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState", + "azure.mgmt.cognitiveservices.models.PublicNetworkAccess": "Microsoft.CognitiveServices.PublicNetworkAccess", + "azure.mgmt.cognitiveservices.models.RoutingMethods": "Microsoft.CognitiveServices.RoutingMethods", + "azure.mgmt.cognitiveservices.models.AbusePenaltyAction": "Microsoft.CognitiveServices.AbusePenaltyAction", + "azure.mgmt.cognitiveservices.models.ScenarioType": "Microsoft.CognitiveServices.ScenarioType", + "azure.mgmt.cognitiveservices.models.SkuTier": "Microsoft.CognitiveServices.SkuTier", + "azure.mgmt.cognitiveservices.models.ResourceIdentityType": "Microsoft.CognitiveServices.ResourceIdentityType", + "azure.mgmt.cognitiveservices.models.KeyName": "Microsoft.CognitiveServices.KeyName", + "azure.mgmt.cognitiveservices.models.UnitType": "Microsoft.CognitiveServices.UnitType", + "azure.mgmt.cognitiveservices.models.QuotaUsageStatus": "Microsoft.CognitiveServices.QuotaUsageStatus", + "azure.mgmt.cognitiveservices.models.DeprecationStatus": "Microsoft.CognitiveServices.DeprecationStatus", + "azure.mgmt.cognitiveservices.models.ModelLifecycleStatus": "Microsoft.CognitiveServices.ModelLifecycleStatus", + "azure.mgmt.cognitiveservices.models.DeploymentProvisioningState": "Microsoft.CognitiveServices.DeploymentProvisioningState", + "azure.mgmt.cognitiveservices.models.DeploymentScaleType": "Microsoft.CognitiveServices.DeploymentScaleType", + "azure.mgmt.cognitiveservices.models.DeploymentModelVersionUpgradeOption": "Microsoft.CognitiveServices.DeploymentModelVersionUpgradeOption", + "azure.mgmt.cognitiveservices.models.ServiceTier": "Microsoft.CognitiveServices.ServiceTier", + "azure.mgmt.cognitiveservices.models.DeploymentState": "Microsoft.CognitiveServices.DeploymentState", + "azure.mgmt.cognitiveservices.models.CommitmentPlanProvisioningState": "Microsoft.CognitiveServices.CommitmentPlanProvisioningState", + "azure.mgmt.cognitiveservices.models.HostingModel": "Microsoft.CognitiveServices.HostingModel", + "azure.mgmt.cognitiveservices.models.EncryptionScopeProvisioningState": "Microsoft.CognitiveServices.EncryptionScopeProvisioningState", + "azure.mgmt.cognitiveservices.models.EncryptionScopeState": "Microsoft.CognitiveServices.EncryptionScopeState", + "azure.mgmt.cognitiveservices.models.RaiPolicyType": "Microsoft.CognitiveServices.RaiPolicyType", + "azure.mgmt.cognitiveservices.models.RaiPolicyMode": "Microsoft.CognitiveServices.RaiPolicyMode", + "azure.mgmt.cognitiveservices.models.ContentLevel": "Microsoft.CognitiveServices.ContentLevel", + "azure.mgmt.cognitiveservices.models.RaiPolicyContentSource": "Microsoft.CognitiveServices.RaiPolicyContentSource", + "azure.mgmt.cognitiveservices.models.RaiActionType": "Microsoft.CognitiveServices.RaiActionType", + "azure.mgmt.cognitiveservices.models.NspAccessRuleDirection": "Microsoft.CognitiveServices.NspAccessRuleDirection", + "azure.mgmt.cognitiveservices.models.DefenderForAISettingState": "Microsoft.CognitiveServices.DefenderForAISettingState", + "azure.mgmt.cognitiveservices.models.ConnectionAuthType": "Microsoft.CognitiveServices.ConnectionAuthType", + "azure.mgmt.cognitiveservices.models.ConnectionCategory": "Microsoft.CognitiveServices.ConnectionCategory", + "azure.mgmt.cognitiveservices.models.ConnectionGroup": "Microsoft.CognitiveServices.ConnectionGroup", + "azure.mgmt.cognitiveservices.models.ManagedPERequirement": "Microsoft.CognitiveServices.ManagedPERequirement", + "azure.mgmt.cognitiveservices.models.ManagedPEStatus": "Microsoft.CognitiveServices.ManagedPEStatus", + "azure.mgmt.cognitiveservices.models.CapabilityHostProvisioningState": "Microsoft.CognitiveServices.CapabilityHostProvisioningState", + "azure.mgmt.cognitiveservices.models.TierUpgradePolicy": "Microsoft.CognitiveServices.TierUpgradePolicy", + "azure.mgmt.cognitiveservices.models.UpgradeAvailabilityStatus": "Microsoft.CognitiveServices.UpgradeAvailabilityStatus", + "azure.mgmt.cognitiveservices.models.IdentityKind": "Microsoft.CognitiveServices.IdentityKind", + "azure.mgmt.cognitiveservices.models.IdentityManagementType": "Microsoft.CognitiveServices.IdentityManagementType", + "azure.mgmt.cognitiveservices.models.IdentityProvisioningState": "Microsoft.CognitiveServices.IdentityProvisioningState", + "azure.mgmt.cognitiveservices.models.BuiltInAuthorizationScheme": "Microsoft.CognitiveServices.BuiltInAuthorizationScheme", + "azure.mgmt.cognitiveservices.models.TrafficRoutingProtocol": "Microsoft.CognitiveServices.TrafficRoutingProtocol", + "azure.mgmt.cognitiveservices.models.AgenticApplicationProvisioningState": "Microsoft.CognitiveServices.AgenticApplicationProvisioningState", + "azure.mgmt.cognitiveservices.models.VmPriority": "Microsoft.CognitiveServices.VmPriority", + "azure.mgmt.cognitiveservices.models.ComputeProvisioningState": "Microsoft.CognitiveServices.ComputeProvisioningState", + "azure.mgmt.cognitiveservices.models.ManagedNetworkStatus": "Microsoft.CognitiveServices.ManagedNetworkStatus", + "azure.mgmt.cognitiveservices.models.CapabilityHostKind": "Microsoft.CognitiveServices.CapabilityHostKind", + "azure.mgmt.cognitiveservices.models.RuleCategory": "Microsoft.CognitiveServices.RuleCategory", + "azure.mgmt.cognitiveservices.models.RuleStatus": "Microsoft.CognitiveServices.RuleStatus", + "azure.mgmt.cognitiveservices.models.RuleType": "Microsoft.CognitiveServices.RuleType", + "azure.mgmt.cognitiveservices.models.IsolationMode": "Microsoft.CognitiveServices.IsolationMode", + "azure.mgmt.cognitiveservices.models.FirewallSku": "Microsoft.CognitiveServices.FirewallSku", + "azure.mgmt.cognitiveservices.models.ManagedNetworkKind": "Microsoft.CognitiveServices.ManagedNetworkKind", + "azure.mgmt.cognitiveservices.models.ManagedNetworkProvisioningState": "Microsoft.CognitiveServices.ManagedNetworkProvisioningState", + "azure.mgmt.cognitiveservices.models.AgentDeploymentState": "Microsoft.CognitiveServices.AgentDeploymentState", + "azure.mgmt.cognitiveservices.models.AgentProtocol": "Microsoft.CognitiveServices.AgentProtocol", + "azure.mgmt.cognitiveservices.models.AgentDeploymentType": "Microsoft.CognitiveServices.AgentDeploymentType", + "azure.mgmt.cognitiveservices.models.AgentDeploymentProvisioningState": "Microsoft.CognitiveServices.AgentDeploymentProvisioningState", + "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType": "Microsoft.CognitiveServices.ResourceSkuRestrictionsType", + "azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode": "Microsoft.CognitiveServices.ResourceSkuRestrictionsReasonCode", + "azure.mgmt.cognitiveservices.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.cognitiveservices.aio.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.get": "Microsoft.CognitiveServices.Accounts.get", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.get": "Microsoft.CognitiveServices.Accounts.get", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.begin_create": "Microsoft.CognitiveServices.Accounts.create", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.begin_create": "Microsoft.CognitiveServices.Accounts.create", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.begin_update": "Microsoft.CognitiveServices.Accounts.update", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.begin_update": "Microsoft.CognitiveServices.Accounts.update", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.begin_delete": "Microsoft.CognitiveServices.Accounts.delete", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.begin_delete": "Microsoft.CognitiveServices.Accounts.delete", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_by_resource_group": "Microsoft.CognitiveServices.Accounts.listByResourceGroup", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_by_resource_group": "Microsoft.CognitiveServices.Accounts.listByResourceGroup", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.list": "Microsoft.CognitiveServices.Accounts.list", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list": "Microsoft.CognitiveServices.Accounts.list", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_keys": "Microsoft.CognitiveServices.Accounts.listKeys", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_keys": "Microsoft.CognitiveServices.Accounts.listKeys", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.regenerate_key": "Microsoft.CognitiveServices.Accounts.regenerateKey", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.regenerate_key": "Microsoft.CognitiveServices.Accounts.regenerateKey", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_skus": "Microsoft.CognitiveServices.Accounts.listSkus", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_skus": "Microsoft.CognitiveServices.Accounts.listSkus", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_usages": "Microsoft.CognitiveServices.Accounts.listUsages", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_usages": "Microsoft.CognitiveServices.Accounts.listUsages", + "azure.mgmt.cognitiveservices.operations.AccountsOperations.list_models": "Microsoft.CognitiveServices.Accounts.listModels", + "azure.mgmt.cognitiveservices.aio.operations.AccountsOperations.list_models": "Microsoft.CognitiveServices.Accounts.listModels", + "azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations.get": "Microsoft.CognitiveServices.DeletedAccounts.get", + "azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations.get": "Microsoft.CognitiveServices.DeletedAccounts.get", + "azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations.begin_purge": "Microsoft.CognitiveServices.DeletedAccounts.purge", + "azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations.begin_purge": "Microsoft.CognitiveServices.DeletedAccounts.purge", + "azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations.list": "Microsoft.CognitiveServices.DeletedAccountsOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations.list": "Microsoft.CognitiveServices.DeletedAccountsOperationGroup.list", + "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.CognitiveServices.PrivateEndpointConnections.get", + "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.CognitiveServices.PrivateEndpointConnections.get", + "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.CognitiveServices.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.begin_create_or_update": "Microsoft.CognitiveServices.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.CognitiveServices.PrivateEndpointConnections.delete", + "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.CognitiveServices.PrivateEndpointConnections.delete", + "azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations.list": "Microsoft.CognitiveServices.PrivateEndpointConnections.list", + "azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations.list": "Microsoft.CognitiveServices.PrivateEndpointConnections.list", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.get": "Microsoft.CognitiveServices.Deployments.get", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.get": "Microsoft.CognitiveServices.Deployments.get", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.begin_create_or_update": "Microsoft.CognitiveServices.Deployments.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.begin_create_or_update": "Microsoft.CognitiveServices.Deployments.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.begin_update": "Microsoft.CognitiveServices.Deployments.update", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.begin_update": "Microsoft.CognitiveServices.Deployments.update", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.begin_delete": "Microsoft.CognitiveServices.Deployments.delete", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.begin_delete": "Microsoft.CognitiveServices.Deployments.delete", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.list": "Microsoft.CognitiveServices.Deployments.list", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.list": "Microsoft.CognitiveServices.Deployments.list", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.list_skus": "Microsoft.CognitiveServices.Deployments.listSkus", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.list_skus": "Microsoft.CognitiveServices.Deployments.listSkus", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.pause": "Microsoft.CognitiveServices.Deployments.pause", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.pause": "Microsoft.CognitiveServices.Deployments.pause", + "azure.mgmt.cognitiveservices.operations.DeploymentsOperations.resume": "Microsoft.CognitiveServices.Deployments.resume", + "azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations.resume": "Microsoft.CognitiveServices.Deployments.resume", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.get": "Microsoft.CognitiveServices.CommitmentPlans.get", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.get": "Microsoft.CognitiveServices.CommitmentPlans.get", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.create_or_update": "Microsoft.CognitiveServices.CommitmentPlans.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.create_or_update": "Microsoft.CognitiveServices.CommitmentPlans.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_delete": "Microsoft.CognitiveServices.CommitmentPlans.delete", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_delete": "Microsoft.CognitiveServices.CommitmentPlans.delete", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list": "Microsoft.CognitiveServices.CommitmentPlans.list", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list": "Microsoft.CognitiveServices.CommitmentPlans.list", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.get_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.getPlan", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.get_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.getPlan", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_create_or_update_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.createOrUpdatePlan", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_create_or_update_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.createOrUpdatePlan", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_update_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.updatePlan", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_update_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.updatePlan", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_delete_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.deletePlan", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_delete_plan": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.deletePlan", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list_plans_by_resource_group": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.listPlansByResourceGroup", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list_plans_by_resource_group": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.listPlansByResourceGroup", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list_plans_by_subscription": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.listPlansBySubscription", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list_plans_by_subscription": "Microsoft.CognitiveServices.CommitmentPlanOperationGroup.listPlansBySubscription", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.get_association": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.getAssociation", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.get_association": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.getAssociation", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_create_or_update_association": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.createOrUpdateAssociation", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_create_or_update_association": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.createOrUpdateAssociation", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.begin_delete_association": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.deleteAssociation", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.begin_delete_association": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.deleteAssociation", + "azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations.list_associations": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.listAssociations", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations.list_associations": "Microsoft.CognitiveServices.CommitmentPlanAccountAssociations.listAssociations", + "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.get": "Microsoft.CognitiveServices.EncryptionScopes.get", + "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.get": "Microsoft.CognitiveServices.EncryptionScopes.get", + "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.create_or_update": "Microsoft.CognitiveServices.EncryptionScopes.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.create_or_update": "Microsoft.CognitiveServices.EncryptionScopes.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.begin_delete": "Microsoft.CognitiveServices.EncryptionScopes.delete", + "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.begin_delete": "Microsoft.CognitiveServices.EncryptionScopes.delete", + "azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations.list": "Microsoft.CognitiveServices.EncryptionScopes.list", + "azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations.list": "Microsoft.CognitiveServices.EncryptionScopes.list", + "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.get": "Microsoft.CognitiveServices.RaiPolicies.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.get": "Microsoft.CognitiveServices.RaiPolicies.get", + "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.create_or_update": "Microsoft.CognitiveServices.RaiPolicies.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.create_or_update": "Microsoft.CognitiveServices.RaiPolicies.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.begin_delete": "Microsoft.CognitiveServices.RaiPolicies.delete", + "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.begin_delete": "Microsoft.CognitiveServices.RaiPolicies.delete", + "azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations.list": "Microsoft.CognitiveServices.RaiPolicies.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations.list": "Microsoft.CognitiveServices.RaiPolicies.list", + "azure.mgmt.cognitiveservices.operations.SubscriptionRaiPolicyOperations.get": "Microsoft.CognitiveServices.SubscriptionRaiPolicy.get", + "azure.mgmt.cognitiveservices.aio.operations.SubscriptionRaiPolicyOperations.get": "Microsoft.CognitiveServices.SubscriptionRaiPolicy.get", + "azure.mgmt.cognitiveservices.operations.SubscriptionRaiPolicyOperations.create_or_update": "Microsoft.CognitiveServices.SubscriptionRaiPolicy.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.SubscriptionRaiPolicyOperations.create_or_update": "Microsoft.CognitiveServices.SubscriptionRaiPolicy.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.SubscriptionRaiPolicyOperations.begin_delete": "Microsoft.CognitiveServices.SubscriptionRaiPolicy.delete", + "azure.mgmt.cognitiveservices.aio.operations.SubscriptionRaiPolicyOperations.begin_delete": "Microsoft.CognitiveServices.SubscriptionRaiPolicy.delete", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.get": "Microsoft.CognitiveServices.RaiBlocklistItems.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.get": "Microsoft.CognitiveServices.RaiBlocklistItems.get", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.create_or_update": "Microsoft.CognitiveServices.RaiBlocklistItems.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.create_or_update": "Microsoft.CognitiveServices.RaiBlocklistItems.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.begin_delete": "Microsoft.CognitiveServices.RaiBlocklistItems.delete", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.begin_delete": "Microsoft.CognitiveServices.RaiBlocklistItems.delete", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.list": "Microsoft.CognitiveServices.RaiBlocklistItems.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.list": "Microsoft.CognitiveServices.RaiBlocklistItems.list", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.batch_add": "Microsoft.CognitiveServices.RaiBlocklists.batchAdd", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.batch_add": "Microsoft.CognitiveServices.RaiBlocklists.batchAdd", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations.batch_delete": "Microsoft.CognitiveServices.RaiBlocklists.batchDelete", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations.batch_delete": "Microsoft.CognitiveServices.RaiBlocklists.batchDelete", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.get": "Microsoft.CognitiveServices.RaiBlocklists.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.get": "Microsoft.CognitiveServices.RaiBlocklists.get", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.create_or_update": "Microsoft.CognitiveServices.RaiBlocklists.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.create_or_update": "Microsoft.CognitiveServices.RaiBlocklists.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.begin_delete": "Microsoft.CognitiveServices.RaiBlocklists.delete", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.begin_delete": "Microsoft.CognitiveServices.RaiBlocklists.delete", + "azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations.list": "Microsoft.CognitiveServices.RaiBlocklists.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations.list": "Microsoft.CognitiveServices.RaiBlocklists.list", + "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.get": "Microsoft.CognitiveServices.RaiTopics.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.get": "Microsoft.CognitiveServices.RaiTopics.get", + "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.create_or_update": "Microsoft.CognitiveServices.RaiTopics.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.create_or_update": "Microsoft.CognitiveServices.RaiTopics.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.begin_delete": "Microsoft.CognitiveServices.RaiTopics.delete", + "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.begin_delete": "Microsoft.CognitiveServices.RaiTopics.delete", + "azure.mgmt.cognitiveservices.operations.RaiTopicsOperations.list": "Microsoft.CognitiveServices.RaiTopics.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations.list": "Microsoft.CognitiveServices.RaiTopics.list", + "azure.mgmt.cognitiveservices.operations.RaiToolLabelsOperations.get": "Microsoft.CognitiveServices.RaiToolLabels.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiToolLabelsOperations.get": "Microsoft.CognitiveServices.RaiToolLabels.get", + "azure.mgmt.cognitiveservices.operations.RaiToolLabelsOperations.create_or_update": "Microsoft.CognitiveServices.RaiToolLabels.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.RaiToolLabelsOperations.create_or_update": "Microsoft.CognitiveServices.RaiToolLabels.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.RaiToolLabelsOperations.begin_delete": "Microsoft.CognitiveServices.RaiToolLabels.delete", + "azure.mgmt.cognitiveservices.aio.operations.RaiToolLabelsOperations.begin_delete": "Microsoft.CognitiveServices.RaiToolLabels.delete", + "azure.mgmt.cognitiveservices.operations.RaiToolLabelsOperations.list": "Microsoft.CognitiveServices.RaiToolLabels.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiToolLabelsOperations.list": "Microsoft.CognitiveServices.RaiToolLabels.list", + "azure.mgmt.cognitiveservices.operations.RaiContentFiltersOperations.get": "Microsoft.CognitiveServices.RaiContentFilters.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiContentFiltersOperations.get": "Microsoft.CognitiveServices.RaiContentFilters.get", + "azure.mgmt.cognitiveservices.operations.RaiContentFiltersOperations.list": "Microsoft.CognitiveServices.RaiContentFilters.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiContentFiltersOperations.list": "Microsoft.CognitiveServices.RaiContentFilters.list", + "azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations.get": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurations.get", + "azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.get": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurations.get", + "azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations.list": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurations.list", + "azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.list": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurations.list", + "azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations.begin_reconcile": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurations.reconcile", + "azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations.begin_reconcile": "Microsoft.CognitiveServices.NetworkSecurityPerimeterConfigurations.reconcile", + "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.get": "Microsoft.CognitiveServices.DefenderForAISettings.get", + "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.get": "Microsoft.CognitiveServices.DefenderForAISettings.get", + "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.create_or_update": "Microsoft.CognitiveServices.DefenderForAISettings.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.create_or_update": "Microsoft.CognitiveServices.DefenderForAISettings.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.update": "Microsoft.CognitiveServices.DefenderForAISettings.update", + "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.update": "Microsoft.CognitiveServices.DefenderForAISettings.update", + "azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations.list": "Microsoft.CognitiveServices.DefenderForAISettings.list", + "azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations.list": "Microsoft.CognitiveServices.DefenderForAISettings.list", + "azure.mgmt.cognitiveservices.operations.ProjectsOperations.get": "Microsoft.CognitiveServices.Projects.get", + "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.get": "Microsoft.CognitiveServices.Projects.get", + "azure.mgmt.cognitiveservices.operations.ProjectsOperations.begin_create": "Microsoft.CognitiveServices.Projects.create", + "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.begin_create": "Microsoft.CognitiveServices.Projects.create", + "azure.mgmt.cognitiveservices.operations.ProjectsOperations.begin_update": "Microsoft.CognitiveServices.Projects.update", + "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.begin_update": "Microsoft.CognitiveServices.Projects.update", + "azure.mgmt.cognitiveservices.operations.ProjectsOperations.begin_delete": "Microsoft.CognitiveServices.Projects.delete", + "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.begin_delete": "Microsoft.CognitiveServices.Projects.delete", + "azure.mgmt.cognitiveservices.operations.ProjectsOperations.list": "Microsoft.CognitiveServices.Projects.list", + "azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations.list": "Microsoft.CognitiveServices.Projects.list", + "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.get": "Microsoft.CognitiveServices.ProjectConnections.get", + "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.get": "Microsoft.CognitiveServices.ProjectConnections.get", + "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.create": "Microsoft.CognitiveServices.ProjectConnections.create", + "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.create": "Microsoft.CognitiveServices.ProjectConnections.create", + "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.update": "Microsoft.CognitiveServices.ProjectConnections.update", + "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.update": "Microsoft.CognitiveServices.ProjectConnections.update", + "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.delete": "Microsoft.CognitiveServices.ProjectConnections.delete", + "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.delete": "Microsoft.CognitiveServices.ProjectConnections.delete", + "azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations.list": "Microsoft.CognitiveServices.ProjectConnections.list", + "azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations.list": "Microsoft.CognitiveServices.ProjectConnections.list", + "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.get": "Microsoft.CognitiveServices.ProjectCapabilityHosts.get", + "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.get": "Microsoft.CognitiveServices.ProjectCapabilityHosts.get", + "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.begin_create_or_update": "Microsoft.CognitiveServices.ProjectCapabilityHosts.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.begin_create_or_update": "Microsoft.CognitiveServices.ProjectCapabilityHosts.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.begin_delete": "Microsoft.CognitiveServices.ProjectCapabilityHosts.delete", + "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.begin_delete": "Microsoft.CognitiveServices.ProjectCapabilityHosts.delete", + "azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations.list": "Microsoft.CognitiveServices.ProjectCapabilityHosts.list", + "azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations.list": "Microsoft.CognitiveServices.ProjectCapabilityHosts.list", + "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.get": "Microsoft.CognitiveServices.QuotaTiers.get", + "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.get": "Microsoft.CognitiveServices.QuotaTiers.get", + "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.create_or_update": "Microsoft.CognitiveServices.QuotaTiers.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.create_or_update": "Microsoft.CognitiveServices.QuotaTiers.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.update": "Microsoft.CognitiveServices.QuotaTiers.update", + "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.update": "Microsoft.CognitiveServices.QuotaTiers.update", + "azure.mgmt.cognitiveservices.operations.QuotaTiersOperations.list_by_subscription": "Microsoft.CognitiveServices.QuotaTiers.listBySubscription", + "azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations.list_by_subscription": "Microsoft.CognitiveServices.QuotaTiers.listBySubscription", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.get": "Microsoft.CognitiveServices.AgentApplications.get", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.get": "Microsoft.CognitiveServices.AgentApplications.get", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.begin_create_or_update": "Microsoft.CognitiveServices.AgentApplications.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.begin_create_or_update": "Microsoft.CognitiveServices.AgentApplications.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.begin_delete": "Microsoft.CognitiveServices.AgentApplications.delete", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.begin_delete": "Microsoft.CognitiveServices.AgentApplications.delete", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.list": "Microsoft.CognitiveServices.AgentApplications.list", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.list": "Microsoft.CognitiveServices.AgentApplications.list", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.list_agents": "Microsoft.CognitiveServices.AgentApplications.listAgents", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.list_agents": "Microsoft.CognitiveServices.AgentApplications.listAgents", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.enable": "Microsoft.CognitiveServices.AgentApplications.enable", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.enable": "Microsoft.CognitiveServices.AgentApplications.enable", + "azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations.disable": "Microsoft.CognitiveServices.AgentApplications.disable", + "azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations.disable": "Microsoft.CognitiveServices.AgentApplications.disable", + "azure.mgmt.cognitiveservices.operations.ComputesOperations.get": "Microsoft.CognitiveServices.Computes.get", + "azure.mgmt.cognitiveservices.aio.operations.ComputesOperations.get": "Microsoft.CognitiveServices.Computes.get", + "azure.mgmt.cognitiveservices.operations.ComputesOperations.begin_create_or_update": "Microsoft.CognitiveServices.Computes.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.ComputesOperations.begin_create_or_update": "Microsoft.CognitiveServices.Computes.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.ComputesOperations.begin_update": "Microsoft.CognitiveServices.Computes.update", + "azure.mgmt.cognitiveservices.aio.operations.ComputesOperations.begin_update": "Microsoft.CognitiveServices.Computes.update", + "azure.mgmt.cognitiveservices.operations.ComputesOperations.begin_delete": "Microsoft.CognitiveServices.Computes.delete", + "azure.mgmt.cognitiveservices.aio.operations.ComputesOperations.begin_delete": "Microsoft.CognitiveServices.Computes.delete", + "azure.mgmt.cognitiveservices.operations.ComputesOperations.list": "Microsoft.CognitiveServices.Computes.list", + "azure.mgmt.cognitiveservices.aio.operations.ComputesOperations.list": "Microsoft.CognitiveServices.Computes.list", + "azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations.list": "Microsoft.CognitiveServices.Accounts.privateLinkResourcesList", + "azure.mgmt.cognitiveservices.aio.operations.PrivateLinkResourcesOperations.list": "Microsoft.CognitiveServices.Accounts.privateLinkResourcesList", + "azure.mgmt.cognitiveservices.operations.TestRaiExternalSafetyProviderOperations.create_or_update": "Microsoft.CognitiveServices.Accounts.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.TestRaiExternalSafetyProviderOperations.create_or_update": "Microsoft.CognitiveServices.Accounts.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.ManagedNetworkProvisionsOperations.begin_provision_managed_network": "Microsoft.CognitiveServices.Accounts.provisionManagedNetwork", + "azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkProvisionsOperations.begin_provision_managed_network": "Microsoft.CognitiveServices.Accounts.provisionManagedNetwork", + "azure.mgmt.cognitiveservices.operations.RaiExternalSafetyProviderOperations.get": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.get", + "azure.mgmt.cognitiveservices.aio.operations.RaiExternalSafetyProviderOperations.get": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.get", + "azure.mgmt.cognitiveservices.operations.RaiExternalSafetyProviderOperations.create_or_update": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.RaiExternalSafetyProviderOperations.create_or_update": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.RaiExternalSafetyProviderOperations.begin_delete": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.delete", + "azure.mgmt.cognitiveservices.aio.operations.RaiExternalSafetyProviderOperations.begin_delete": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.delete", + "azure.mgmt.cognitiveservices.operations.RaiExternalSafetyProvidersOperations.list": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.list", + "azure.mgmt.cognitiveservices.aio.operations.RaiExternalSafetyProvidersOperations.list": "Microsoft.CognitiveServices.RaiExternalSafetyProviderSchemas.list", + "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.get": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.get", + "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.get": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.get", + "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.create": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.create", + "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.create": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.create", + "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.update": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.update", + "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.update": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.update", + "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.delete": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.delete", + "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.delete": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.delete", + "azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations.list": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.list", + "azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations.list": "Microsoft.CognitiveServices.ConnectionPropertiesV2BasicResources.list", + "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.get": "Microsoft.CognitiveServices.CapabilityHosts.get", + "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.get": "Microsoft.CognitiveServices.CapabilityHosts.get", + "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.begin_create_or_update": "Microsoft.CognitiveServices.CapabilityHosts.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.begin_create_or_update": "Microsoft.CognitiveServices.CapabilityHosts.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.begin_delete": "Microsoft.CognitiveServices.CapabilityHosts.delete", + "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.begin_delete": "Microsoft.CognitiveServices.CapabilityHosts.delete", + "azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations.list": "Microsoft.CognitiveServices.CapabilityHosts.list", + "azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations.list": "Microsoft.CognitiveServices.CapabilityHosts.list", + "azure.mgmt.cognitiveservices.operations.OutboundRuleOperations.get": "Microsoft.CognitiveServices.OutboundRuleBasicResources.get", + "azure.mgmt.cognitiveservices.aio.operations.OutboundRuleOperations.get": "Microsoft.CognitiveServices.OutboundRuleBasicResources.get", + "azure.mgmt.cognitiveservices.operations.OutboundRuleOperations.begin_create_or_update": "Microsoft.CognitiveServices.OutboundRuleBasicResources.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.OutboundRuleOperations.begin_create_or_update": "Microsoft.CognitiveServices.OutboundRuleBasicResources.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.OutboundRuleOperations.begin_delete": "Microsoft.CognitiveServices.OutboundRuleBasicResources.delete", + "azure.mgmt.cognitiveservices.aio.operations.OutboundRuleOperations.begin_delete": "Microsoft.CognitiveServices.OutboundRuleBasicResources.delete", + "azure.mgmt.cognitiveservices.operations.OutboundRuleOperations.list": "Microsoft.CognitiveServices.OutboundRuleBasicResources.list", + "azure.mgmt.cognitiveservices.aio.operations.OutboundRuleOperations.list": "Microsoft.CognitiveServices.OutboundRuleBasicResources.list", + "azure.mgmt.cognitiveservices.operations.ManagedNetworkSettingsOperations.get": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.get", + "azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkSettingsOperations.get": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.get", + "azure.mgmt.cognitiveservices.operations.ManagedNetworkSettingsOperations.begin_put": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.put", + "azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkSettingsOperations.begin_put": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.put", + "azure.mgmt.cognitiveservices.operations.ManagedNetworkSettingsOperations.begin_patch": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.patch", + "azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkSettingsOperations.begin_patch": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.patch", + "azure.mgmt.cognitiveservices.operations.ManagedNetworkSettingsOperations.list": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.list", + "azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkSettingsOperations.list": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.list", + "azure.mgmt.cognitiveservices.operations.OutboundRulesOperations.begin_post": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.post", + "azure.mgmt.cognitiveservices.aio.operations.OutboundRulesOperations.begin_post": "Microsoft.CognitiveServices.ManagedNetworkSettingsPropertiesBasicResources.post", + "azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations.get": "Microsoft.CognitiveServices.AgentDeploymentResources.get", + "azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations.get": "Microsoft.CognitiveServices.AgentDeploymentResources.get", + "azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations.begin_create_or_update": "Microsoft.CognitiveServices.AgentDeploymentResources.createOrUpdate", + "azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations.begin_create_or_update": "Microsoft.CognitiveServices.AgentDeploymentResources.createOrUpdate", + "azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations.begin_delete": "Microsoft.CognitiveServices.AgentDeploymentResources.delete", + "azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations.begin_delete": "Microsoft.CognitiveServices.AgentDeploymentResources.delete", + "azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations.list": "Microsoft.CognitiveServices.AgentDeploymentResources.list", + "azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations.list": "Microsoft.CognitiveServices.AgentDeploymentResources.list", + "azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations.start": "Microsoft.CognitiveServices.AgentDeploymentResources.start", + "azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations.start": "Microsoft.CognitiveServices.AgentDeploymentResources.start", + "azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations.stop": "Microsoft.CognitiveServices.AgentDeploymentResources.stop", + "azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations.stop": "Microsoft.CognitiveServices.AgentDeploymentResources.stop", + "azure.mgmt.cognitiveservices.operations.ResourceSkusOperations.list": "Microsoft.CognitiveServices.ResourceSkusOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.ResourceSkusOperations.list": "Microsoft.CognitiveServices.ResourceSkusOperationGroup.list", + "azure.mgmt.cognitiveservices.operations.UsagesOperations.list": "Microsoft.CognitiveServices.UsagesOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.UsagesOperations.list": "Microsoft.CognitiveServices.UsagesOperationGroup.list", + "azure.mgmt.cognitiveservices.operations.CommitmentTiersOperations.list": "Microsoft.CognitiveServices.CommitmentTiersOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.CommitmentTiersOperations.list": "Microsoft.CognitiveServices.CommitmentTiersOperationGroup.list", + "azure.mgmt.cognitiveservices.operations.ModelsOperations.list": "Microsoft.CognitiveServices.ModelsOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.ModelsOperations.list": "Microsoft.CognitiveServices.ModelsOperationGroup.list", + "azure.mgmt.cognitiveservices.operations.LocationBasedModelCapacitiesOperations.list": "Microsoft.CognitiveServices.LocationBasedModelCapacitiesOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.LocationBasedModelCapacitiesOperations.list": "Microsoft.CognitiveServices.LocationBasedModelCapacitiesOperationGroup.list", + "azure.mgmt.cognitiveservices.operations.ModelCapacitiesOperations.list": "Microsoft.CognitiveServices.ModelCapacitiesOperationGroup.list", + "azure.mgmt.cognitiveservices.aio.operations.ModelCapacitiesOperations.list": "Microsoft.CognitiveServices.ModelCapacitiesOperationGroup.list", + "azure.mgmt.cognitiveservices.CognitiveServicesManagementClient.check_sku_availability": "Microsoft.CognitiveServices.checkSkuAvailability", + "azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient.check_sku_availability": "Microsoft.CognitiveServices.checkSkuAvailability", + "azure.mgmt.cognitiveservices.CognitiveServicesManagementClient.check_domain_availability": "Microsoft.CognitiveServices.checkDomainAvailability", + "azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient.check_domain_availability": "Microsoft.CognitiveServices.checkDomainAvailability", + "azure.mgmt.cognitiveservices.CognitiveServicesManagementClient.calculate_model_capacity": "Microsoft.CognitiveServices.calculateModelCapacity", + "azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient.calculate_model_capacity": "Microsoft.CognitiveServices.calculateModelCapacity" } } \ No newline at end of file diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py index cf2ee8a715df..a3af69434316 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._cognitive_services_management_client import CognitiveServicesManagementClient # type: ignore +from ._client import CognitiveServicesManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_client.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_client.py new file mode 100644 index 000000000000..a23aeeb89d0f --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_client.py @@ -0,0 +1,358 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints + +from ._configuration import CognitiveServicesManagementClientConfiguration +from ._utils.serialization import Deserializer, Serializer +from .operations import ( + AccountCapabilityHostsOperations, + AccountConnectionsOperations, + AccountsOperations, + AgentApplicationsOperations, + AgentDeploymentsOperations, + CommitmentPlansOperations, + CommitmentTiersOperations, + ComputesOperations, + DefenderForAISettingsOperations, + DeletedAccountsOperations, + DeploymentsOperations, + EncryptionScopesOperations, + LocationBasedModelCapacitiesOperations, + ManagedNetworkProvisionsOperations, + ManagedNetworkSettingsOperations, + ModelCapacitiesOperations, + ModelsOperations, + NetworkSecurityPerimeterConfigurationsOperations, + Operations, + OutboundRuleOperations, + OutboundRulesOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ProjectCapabilityHostsOperations, + ProjectConnectionsOperations, + ProjectsOperations, + QuotaTiersOperations, + RaiBlocklistItemsOperations, + RaiBlocklistsOperations, + RaiContentFiltersOperations, + RaiExternalSafetyProviderOperations, + RaiExternalSafetyProvidersOperations, + RaiPoliciesOperations, + RaiToolLabelsOperations, + RaiTopicsOperations, + ResourceSkusOperations, + SubscriptionRaiPolicyOperations, + TestRaiExternalSafetyProviderOperations, + UsagesOperations, + _CognitiveServicesManagementClientOperationsMixin, +) + +if TYPE_CHECKING: + from azure.core import AzureClouds + from azure.core.credentials import TokenCredential + + +class CognitiveServicesManagementClient( + _CognitiveServicesManagementClientOperationsMixin +): # pylint: disable=too-many-instance-attributes + """Cognitive Services Management Client. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.cognitiveservices.operations.Operations + :ivar accounts: AccountsOperations operations + :vartype accounts: azure.mgmt.cognitiveservices.operations.AccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: azure.mgmt.cognitiveservices.operations.DeletedAccountsOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.cognitiveservices.operations.PrivateEndpointConnectionsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.cognitiveservices.operations.DeploymentsOperations + :ivar commitment_plans: CommitmentPlansOperations operations + :vartype commitment_plans: azure.mgmt.cognitiveservices.operations.CommitmentPlansOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: azure.mgmt.cognitiveservices.operations.EncryptionScopesOperations + :ivar rai_policies: RaiPoliciesOperations operations + :vartype rai_policies: azure.mgmt.cognitiveservices.operations.RaiPoliciesOperations + :ivar subscription_rai_policy: SubscriptionRaiPolicyOperations operations + :vartype subscription_rai_policy: + azure.mgmt.cognitiveservices.operations.SubscriptionRaiPolicyOperations + :ivar rai_blocklist_items: RaiBlocklistItemsOperations operations + :vartype rai_blocklist_items: + azure.mgmt.cognitiveservices.operations.RaiBlocklistItemsOperations + :ivar rai_blocklists: RaiBlocklistsOperations operations + :vartype rai_blocklists: azure.mgmt.cognitiveservices.operations.RaiBlocklistsOperations + :ivar rai_topics: RaiTopicsOperations operations + :vartype rai_topics: azure.mgmt.cognitiveservices.operations.RaiTopicsOperations + :ivar rai_tool_labels: RaiToolLabelsOperations operations + :vartype rai_tool_labels: azure.mgmt.cognitiveservices.operations.RaiToolLabelsOperations + :ivar rai_content_filters: RaiContentFiltersOperations operations + :vartype rai_content_filters: + azure.mgmt.cognitiveservices.operations.RaiContentFiltersOperations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.cognitiveservices.operations.NetworkSecurityPerimeterConfigurationsOperations + :ivar defender_for_ai_settings: DefenderForAISettingsOperations operations + :vartype defender_for_ai_settings: + azure.mgmt.cognitiveservices.operations.DefenderForAISettingsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.mgmt.cognitiveservices.operations.ProjectsOperations + :ivar project_connections: ProjectConnectionsOperations operations + :vartype project_connections: + azure.mgmt.cognitiveservices.operations.ProjectConnectionsOperations + :ivar project_capability_hosts: ProjectCapabilityHostsOperations operations + :vartype project_capability_hosts: + azure.mgmt.cognitiveservices.operations.ProjectCapabilityHostsOperations + :ivar quota_tiers: QuotaTiersOperations operations + :vartype quota_tiers: azure.mgmt.cognitiveservices.operations.QuotaTiersOperations + :ivar agent_applications: AgentApplicationsOperations operations + :vartype agent_applications: + azure.mgmt.cognitiveservices.operations.AgentApplicationsOperations + :ivar computes: ComputesOperations operations + :vartype computes: azure.mgmt.cognitiveservices.operations.ComputesOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.cognitiveservices.operations.PrivateLinkResourcesOperations + :ivar test_rai_external_safety_provider: TestRaiExternalSafetyProviderOperations operations + :vartype test_rai_external_safety_provider: + azure.mgmt.cognitiveservices.operations.TestRaiExternalSafetyProviderOperations + :ivar managed_network_provisions: ManagedNetworkProvisionsOperations operations + :vartype managed_network_provisions: + azure.mgmt.cognitiveservices.operations.ManagedNetworkProvisionsOperations + :ivar rai_external_safety_provider: RaiExternalSafetyProviderOperations operations + :vartype rai_external_safety_provider: + azure.mgmt.cognitiveservices.operations.RaiExternalSafetyProviderOperations + :ivar rai_external_safety_providers: RaiExternalSafetyProvidersOperations operations + :vartype rai_external_safety_providers: + azure.mgmt.cognitiveservices.operations.RaiExternalSafetyProvidersOperations + :ivar account_connections: AccountConnectionsOperations operations + :vartype account_connections: + azure.mgmt.cognitiveservices.operations.AccountConnectionsOperations + :ivar account_capability_hosts: AccountCapabilityHostsOperations operations + :vartype account_capability_hosts: + azure.mgmt.cognitiveservices.operations.AccountCapabilityHostsOperations + :ivar outbound_rule: OutboundRuleOperations operations + :vartype outbound_rule: azure.mgmt.cognitiveservices.operations.OutboundRuleOperations + :ivar managed_network_settings: ManagedNetworkSettingsOperations operations + :vartype managed_network_settings: + azure.mgmt.cognitiveservices.operations.ManagedNetworkSettingsOperations + :ivar outbound_rules: OutboundRulesOperations operations + :vartype outbound_rules: azure.mgmt.cognitiveservices.operations.OutboundRulesOperations + :ivar agent_deployments: AgentDeploymentsOperations operations + :vartype agent_deployments: azure.mgmt.cognitiveservices.operations.AgentDeploymentsOperations + :ivar resource_skus: ResourceSkusOperations operations + :vartype resource_skus: azure.mgmt.cognitiveservices.operations.ResourceSkusOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.cognitiveservices.operations.UsagesOperations + :ivar commitment_tiers: CommitmentTiersOperations operations + :vartype commitment_tiers: azure.mgmt.cognitiveservices.operations.CommitmentTiersOperations + :ivar models: ModelsOperations operations + :vartype models: azure.mgmt.cognitiveservices.operations.ModelsOperations + :ivar location_based_model_capacities: LocationBasedModelCapacitiesOperations operations + :vartype location_based_model_capacities: + azure.mgmt.cognitiveservices.operations.LocationBasedModelCapacitiesOperations + :ivar model_capacities: ModelCapacitiesOperations operations + :vartype model_capacities: azure.mgmt.cognitiveservices.operations.ModelCapacitiesOperations + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service host. Default value is None. + :type base_url: str + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-10-01-preview" and None. Default value is "2025-10-01-preview". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = CognitiveServicesManagementClientConfiguration( + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_plans = CommitmentPlansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_policies = RaiPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_rai_policy = SubscriptionRaiPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_blocklist_items = RaiBlocklistItemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_blocklists = RaiBlocklistsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rai_topics = RaiTopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rai_tool_labels = RaiToolLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rai_content_filters = RaiContentFiltersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.defender_for_ai_settings = DefenderForAISettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.project_connections = ProjectConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.project_capability_hosts = ProjectCapabilityHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_tiers = QuotaTiersOperations(self._client, self._config, self._serialize, self._deserialize) + self.agent_applications = AgentApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.computes = ComputesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test_rai_external_safety_provider = TestRaiExternalSafetyProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_network_provisions = ManagedNetworkProvisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_external_safety_provider = RaiExternalSafetyProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_external_safety_providers = RaiExternalSafetyProvidersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.account_connections = AccountConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.account_capability_hosts = AccountCapabilityHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_rule = OutboundRuleOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_network_settings = ManagedNetworkSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_rules = OutboundRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.agent_deployments = AgentDeploymentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_tiers = CommitmentTiersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.models = ModelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.location_based_model_capacities = LocationBasedModelCapacitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.model_capacities = ModelCapacitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py index f93e034e40af..60d1adae5a90 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,14 +24,17 @@ class CognitiveServicesManagementClientConfiguration: # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-09-01". Note that overriding this + :keyword api_version: The API version to use for this operation. Known values are + "2025-10-01-preview" and None. Default value is "2025-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -40,10 +43,11 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-09-01") + api_version: str = kwargs.pop("api_version", "2025-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,6 +56,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/__init__.py @@ -1,6 +1,6 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/model_base.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/model_base.py new file mode 100644 index 000000000000..9616929f7415 --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/model_base.py @@ -0,0 +1,1362 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { + Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf + for attr, rf in cls._attr_to_rest_field.items() + } + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: + rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access + if rest_field_obj is None: + return attr_name + original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access + if original_tsp_name: + return original_tsp_name + return attr_name + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._original_tsp_name = original_tsp_name + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + original_tsp_name=original_tsp_name, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/serialization.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/serialization.py index ff543ed937ff..81ec1de5922b 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/serialization.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/serialization.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -821,13 +821,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1757,7 +1764,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1783,7 +1790,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/utils.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/utils.py index 39b612f39a9b..35c9c836f85f 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/utils.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/_utils/utils.py @@ -1,7 +1,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py index 7ac2db0cdcfd..a2bbd7ed484c 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._cognitive_services_management_client import CognitiveServicesManagementClient # type: ignore +from ._client import CognitiveServicesManagementClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_client.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_client.py new file mode 100644 index 000000000000..45e04c306a6b --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_client.py @@ -0,0 +1,368 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints + +from .._utils.serialization import Deserializer, Serializer +from ._configuration import CognitiveServicesManagementClientConfiguration +from .operations import ( + AccountCapabilityHostsOperations, + AccountConnectionsOperations, + AccountsOperations, + AgentApplicationsOperations, + AgentDeploymentsOperations, + CommitmentPlansOperations, + CommitmentTiersOperations, + ComputesOperations, + DefenderForAISettingsOperations, + DeletedAccountsOperations, + DeploymentsOperations, + EncryptionScopesOperations, + LocationBasedModelCapacitiesOperations, + ManagedNetworkProvisionsOperations, + ManagedNetworkSettingsOperations, + ModelCapacitiesOperations, + ModelsOperations, + NetworkSecurityPerimeterConfigurationsOperations, + Operations, + OutboundRuleOperations, + OutboundRulesOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ProjectCapabilityHostsOperations, + ProjectConnectionsOperations, + ProjectsOperations, + QuotaTiersOperations, + RaiBlocklistItemsOperations, + RaiBlocklistsOperations, + RaiContentFiltersOperations, + RaiExternalSafetyProviderOperations, + RaiExternalSafetyProvidersOperations, + RaiPoliciesOperations, + RaiToolLabelsOperations, + RaiTopicsOperations, + ResourceSkusOperations, + SubscriptionRaiPolicyOperations, + TestRaiExternalSafetyProviderOperations, + UsagesOperations, + _CognitiveServicesManagementClientOperationsMixin, +) + +if TYPE_CHECKING: + from azure.core import AzureClouds + from azure.core.credentials_async import AsyncTokenCredential + + +class CognitiveServicesManagementClient( + _CognitiveServicesManagementClientOperationsMixin +): # pylint: disable=too-many-instance-attributes + """Cognitive Services Management Client. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.cognitiveservices.aio.operations.Operations + :ivar accounts: AccountsOperations operations + :vartype accounts: azure.mgmt.cognitiveservices.aio.operations.AccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: + azure.mgmt.cognitiveservices.aio.operations.DeletedAccountsOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.cognitiveservices.aio.operations.PrivateEndpointConnectionsOperations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.cognitiveservices.aio.operations.DeploymentsOperations + :ivar commitment_plans: CommitmentPlansOperations operations + :vartype commitment_plans: + azure.mgmt.cognitiveservices.aio.operations.CommitmentPlansOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.cognitiveservices.aio.operations.EncryptionScopesOperations + :ivar rai_policies: RaiPoliciesOperations operations + :vartype rai_policies: azure.mgmt.cognitiveservices.aio.operations.RaiPoliciesOperations + :ivar subscription_rai_policy: SubscriptionRaiPolicyOperations operations + :vartype subscription_rai_policy: + azure.mgmt.cognitiveservices.aio.operations.SubscriptionRaiPolicyOperations + :ivar rai_blocklist_items: RaiBlocklistItemsOperations operations + :vartype rai_blocklist_items: + azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistItemsOperations + :ivar rai_blocklists: RaiBlocklistsOperations operations + :vartype rai_blocklists: azure.mgmt.cognitiveservices.aio.operations.RaiBlocklistsOperations + :ivar rai_topics: RaiTopicsOperations operations + :vartype rai_topics: azure.mgmt.cognitiveservices.aio.operations.RaiTopicsOperations + :ivar rai_tool_labels: RaiToolLabelsOperations operations + :vartype rai_tool_labels: azure.mgmt.cognitiveservices.aio.operations.RaiToolLabelsOperations + :ivar rai_content_filters: RaiContentFiltersOperations operations + :vartype rai_content_filters: + azure.mgmt.cognitiveservices.aio.operations.RaiContentFiltersOperations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.cognitiveservices.aio.operations.NetworkSecurityPerimeterConfigurationsOperations + :ivar defender_for_ai_settings: DefenderForAISettingsOperations operations + :vartype defender_for_ai_settings: + azure.mgmt.cognitiveservices.aio.operations.DefenderForAISettingsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.mgmt.cognitiveservices.aio.operations.ProjectsOperations + :ivar project_connections: ProjectConnectionsOperations operations + :vartype project_connections: + azure.mgmt.cognitiveservices.aio.operations.ProjectConnectionsOperations + :ivar project_capability_hosts: ProjectCapabilityHostsOperations operations + :vartype project_capability_hosts: + azure.mgmt.cognitiveservices.aio.operations.ProjectCapabilityHostsOperations + :ivar quota_tiers: QuotaTiersOperations operations + :vartype quota_tiers: azure.mgmt.cognitiveservices.aio.operations.QuotaTiersOperations + :ivar agent_applications: AgentApplicationsOperations operations + :vartype agent_applications: + azure.mgmt.cognitiveservices.aio.operations.AgentApplicationsOperations + :ivar computes: ComputesOperations operations + :vartype computes: azure.mgmt.cognitiveservices.aio.operations.ComputesOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.cognitiveservices.aio.operations.PrivateLinkResourcesOperations + :ivar test_rai_external_safety_provider: TestRaiExternalSafetyProviderOperations operations + :vartype test_rai_external_safety_provider: + azure.mgmt.cognitiveservices.aio.operations.TestRaiExternalSafetyProviderOperations + :ivar managed_network_provisions: ManagedNetworkProvisionsOperations operations + :vartype managed_network_provisions: + azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkProvisionsOperations + :ivar rai_external_safety_provider: RaiExternalSafetyProviderOperations operations + :vartype rai_external_safety_provider: + azure.mgmt.cognitiveservices.aio.operations.RaiExternalSafetyProviderOperations + :ivar rai_external_safety_providers: RaiExternalSafetyProvidersOperations operations + :vartype rai_external_safety_providers: + azure.mgmt.cognitiveservices.aio.operations.RaiExternalSafetyProvidersOperations + :ivar account_connections: AccountConnectionsOperations operations + :vartype account_connections: + azure.mgmt.cognitiveservices.aio.operations.AccountConnectionsOperations + :ivar account_capability_hosts: AccountCapabilityHostsOperations operations + :vartype account_capability_hosts: + azure.mgmt.cognitiveservices.aio.operations.AccountCapabilityHostsOperations + :ivar outbound_rule: OutboundRuleOperations operations + :vartype outbound_rule: azure.mgmt.cognitiveservices.aio.operations.OutboundRuleOperations + :ivar managed_network_settings: ManagedNetworkSettingsOperations operations + :vartype managed_network_settings: + azure.mgmt.cognitiveservices.aio.operations.ManagedNetworkSettingsOperations + :ivar outbound_rules: OutboundRulesOperations operations + :vartype outbound_rules: azure.mgmt.cognitiveservices.aio.operations.OutboundRulesOperations + :ivar agent_deployments: AgentDeploymentsOperations operations + :vartype agent_deployments: + azure.mgmt.cognitiveservices.aio.operations.AgentDeploymentsOperations + :ivar resource_skus: ResourceSkusOperations operations + :vartype resource_skus: azure.mgmt.cognitiveservices.aio.operations.ResourceSkusOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.cognitiveservices.aio.operations.UsagesOperations + :ivar commitment_tiers: CommitmentTiersOperations operations + :vartype commitment_tiers: + azure.mgmt.cognitiveservices.aio.operations.CommitmentTiersOperations + :ivar models: ModelsOperations operations + :vartype models: azure.mgmt.cognitiveservices.aio.operations.ModelsOperations + :ivar location_based_model_capacities: LocationBasedModelCapacitiesOperations operations + :vartype location_based_model_capacities: + azure.mgmt.cognitiveservices.aio.operations.LocationBasedModelCapacitiesOperations + :ivar model_capacities: ModelCapacitiesOperations operations + :vartype model_capacities: + azure.mgmt.cognitiveservices.aio.operations.ModelCapacitiesOperations + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service host. Default value is None. + :type base_url: str + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-10-01-preview" and None. Default value is "2025-10-01-preview". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = CognitiveServicesManagementClientConfiguration( + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_plans = CommitmentPlansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_policies = RaiPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_rai_policy = SubscriptionRaiPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_blocklist_items = RaiBlocklistItemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_blocklists = RaiBlocklistsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rai_topics = RaiTopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rai_tool_labels = RaiToolLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.rai_content_filters = RaiContentFiltersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.defender_for_ai_settings = DefenderForAISettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.project_connections = ProjectConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.project_capability_hosts = ProjectCapabilityHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_tiers = QuotaTiersOperations(self._client, self._config, self._serialize, self._deserialize) + self.agent_applications = AgentApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.computes = ComputesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.test_rai_external_safety_provider = TestRaiExternalSafetyProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_network_provisions = ManagedNetworkProvisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_external_safety_provider = RaiExternalSafetyProviderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.rai_external_safety_providers = RaiExternalSafetyProvidersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.account_connections = AccountConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.account_capability_hosts = AccountCapabilityHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_rule = OutboundRuleOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_network_settings = ManagedNetworkSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.outbound_rules = OutboundRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.agent_deployments = AgentDeploymentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.commitment_tiers = CommitmentTiersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.models = ModelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.location_based_model_capacities = LocationBasedModelCapacitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.model_capacities = ModelCapacitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py index b0cbe0e95af4..56875727d03a 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,14 +24,17 @@ class CognitiveServicesManagementClientConfiguration: # pylint: disable=too-man Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds - :keyword api_version: Api Version. Default value is "2025-09-01". Note that overriding this + :keyword api_version: The API version to use for this operation. Known values are + "2025-10-01-preview" and None. Default value is "2025-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -40,10 +43,11 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-09-01") + api_version: str = kwargs.pop("api_version", "2025-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,6 +56,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py index cac37cb8c8a9..5dd741ca6d41 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/__init__.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,67 +13,91 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._accounts_operations import AccountsOperations # type: ignore -from ._deleted_accounts_operations import DeletedAccountsOperations # type: ignore -from ._resource_skus_operations import ResourceSkusOperations # type: ignore -from ._usages_operations import UsagesOperations # type: ignore from ._operations import Operations # type: ignore -from ._cognitive_services_management_client_operations import _CognitiveServicesManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import -from ._commitment_tiers_operations import CommitmentTiersOperations # type: ignore -from ._models_operations import ModelsOperations # type: ignore -from ._location_based_model_capacities_operations import LocationBasedModelCapacitiesOperations # type: ignore -from ._model_capacities_operations import ModelCapacitiesOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._deployments_operations import DeploymentsOperations # type: ignore -from ._commitment_plans_operations import CommitmentPlansOperations # type: ignore -from ._encryption_scopes_operations import EncryptionScopesOperations # type: ignore -from ._rai_policies_operations import RaiPoliciesOperations # type: ignore -from ._rai_blocklists_operations import RaiBlocklistsOperations # type: ignore -from ._rai_blocklist_items_operations import RaiBlocklistItemsOperations # type: ignore -from ._rai_topics_operations import RaiTopicsOperations # type: ignore -from ._rai_content_filters_operations import RaiContentFiltersOperations # type: ignore -from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore -from ._defender_for_ai_settings_operations import DefenderForAISettingsOperations # type: ignore -from ._projects_operations import ProjectsOperations # type: ignore -from ._account_connections_operations import AccountConnectionsOperations # type: ignore -from ._project_connections_operations import ProjectConnectionsOperations # type: ignore -from ._account_capability_hosts_operations import AccountCapabilityHostsOperations # type: ignore -from ._project_capability_hosts_operations import ProjectCapabilityHostsOperations # type: ignore -from ._quota_tiers_operations import QuotaTiersOperations # type: ignore +from ._operations import AccountsOperations # type: ignore +from ._operations import DeletedAccountsOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import DeploymentsOperations # type: ignore +from ._operations import CommitmentPlansOperations # type: ignore +from ._operations import EncryptionScopesOperations # type: ignore +from ._operations import RaiPoliciesOperations # type: ignore +from ._operations import SubscriptionRaiPolicyOperations # type: ignore +from ._operations import RaiBlocklistItemsOperations # type: ignore +from ._operations import RaiBlocklistsOperations # type: ignore +from ._operations import RaiTopicsOperations # type: ignore +from ._operations import RaiToolLabelsOperations # type: ignore +from ._operations import RaiContentFiltersOperations # type: ignore +from ._operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore +from ._operations import DefenderForAISettingsOperations # type: ignore +from ._operations import ProjectsOperations # type: ignore +from ._operations import ProjectConnectionsOperations # type: ignore +from ._operations import ProjectCapabilityHostsOperations # type: ignore +from ._operations import QuotaTiersOperations # type: ignore +from ._operations import AgentApplicationsOperations # type: ignore +from ._operations import ComputesOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import TestRaiExternalSafetyProviderOperations # type: ignore +from ._operations import ManagedNetworkProvisionsOperations # type: ignore +from ._operations import RaiExternalSafetyProviderOperations # type: ignore +from ._operations import RaiExternalSafetyProvidersOperations # type: ignore +from ._operations import AccountConnectionsOperations # type: ignore +from ._operations import AccountCapabilityHostsOperations # type: ignore +from ._operations import OutboundRuleOperations # type: ignore +from ._operations import ManagedNetworkSettingsOperations # type: ignore +from ._operations import OutboundRulesOperations # type: ignore +from ._operations import AgentDeploymentsOperations # type: ignore +from ._operations import ResourceSkusOperations # type: ignore +from ._operations import UsagesOperations # type: ignore +from ._operations import CommitmentTiersOperations # type: ignore +from ._operations import ModelsOperations # type: ignore +from ._operations import LocationBasedModelCapacitiesOperations # type: ignore +from ._operations import ModelCapacitiesOperations # type: ignore +from ._operations import _CognitiveServicesManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Operations", "AccountsOperations", "DeletedAccountsOperations", - "ResourceSkusOperations", - "UsagesOperations", - "Operations", - "CommitmentTiersOperations", - "ModelsOperations", - "LocationBasedModelCapacitiesOperations", - "ModelCapacitiesOperations", "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", "DeploymentsOperations", "CommitmentPlansOperations", "EncryptionScopesOperations", "RaiPoliciesOperations", - "RaiBlocklistsOperations", + "SubscriptionRaiPolicyOperations", "RaiBlocklistItemsOperations", + "RaiBlocklistsOperations", "RaiTopicsOperations", + "RaiToolLabelsOperations", "RaiContentFiltersOperations", "NetworkSecurityPerimeterConfigurationsOperations", "DefenderForAISettingsOperations", "ProjectsOperations", - "AccountConnectionsOperations", "ProjectConnectionsOperations", - "AccountCapabilityHostsOperations", "ProjectCapabilityHostsOperations", "QuotaTiersOperations", + "AgentApplicationsOperations", + "ComputesOperations", + "PrivateLinkResourcesOperations", + "TestRaiExternalSafetyProviderOperations", + "ManagedNetworkProvisionsOperations", + "RaiExternalSafetyProviderOperations", + "RaiExternalSafetyProvidersOperations", + "AccountConnectionsOperations", + "AccountCapabilityHostsOperations", + "OutboundRuleOperations", + "ManagedNetworkSettingsOperations", + "OutboundRulesOperations", + "AgentDeploymentsOperations", + "ResourceSkusOperations", + "UsagesOperations", + "CommitmentTiersOperations", + "ModelsOperations", + "LocationBasedModelCapacitiesOperations", + "ModelCapacitiesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py index e4e3fee0422c..44f30b2e6c8d 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/aio/operations/_operations.py @@ -1,12 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -17,21 +20,179 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_list_request +from ..._utils.utils import ClientMixinABC +from ...operations._operations import ( + build_account_capability_hosts_create_or_update_request, + build_account_capability_hosts_delete_request, + build_account_capability_hosts_get_request, + build_account_capability_hosts_list_request, + build_account_connections_create_request, + build_account_connections_delete_request, + build_account_connections_get_request, + build_account_connections_list_request, + build_account_connections_update_request, + build_accounts_create_request, + build_accounts_delete_request, + build_accounts_get_request, + build_accounts_list_by_resource_group_request, + build_accounts_list_keys_request, + build_accounts_list_models_request, + build_accounts_list_request, + build_accounts_list_skus_request, + build_accounts_list_usages_request, + build_accounts_regenerate_key_request, + build_accounts_update_request, + build_agent_applications_create_or_update_request, + build_agent_applications_delete_request, + build_agent_applications_disable_request, + build_agent_applications_enable_request, + build_agent_applications_get_request, + build_agent_applications_list_agents_request, + build_agent_applications_list_request, + build_agent_deployments_create_or_update_request, + build_agent_deployments_delete_request, + build_agent_deployments_get_request, + build_agent_deployments_list_request, + build_agent_deployments_start_request, + build_agent_deployments_stop_request, + build_cognitive_services_management_calculate_model_capacity_request, + build_cognitive_services_management_check_domain_availability_request, + build_cognitive_services_management_check_sku_availability_request, + build_commitment_plans_create_or_update_association_request, + build_commitment_plans_create_or_update_plan_request, + build_commitment_plans_create_or_update_request, + build_commitment_plans_delete_association_request, + build_commitment_plans_delete_plan_request, + build_commitment_plans_delete_request, + build_commitment_plans_get_association_request, + build_commitment_plans_get_plan_request, + build_commitment_plans_get_request, + build_commitment_plans_list_associations_request, + build_commitment_plans_list_plans_by_resource_group_request, + build_commitment_plans_list_plans_by_subscription_request, + build_commitment_plans_list_request, + build_commitment_plans_update_plan_request, + build_commitment_tiers_list_request, + build_computes_create_or_update_request, + build_computes_delete_request, + build_computes_get_request, + build_computes_list_request, + build_computes_update_request, + build_defender_for_ai_settings_create_or_update_request, + build_defender_for_ai_settings_get_request, + build_defender_for_ai_settings_list_request, + build_defender_for_ai_settings_update_request, + build_deleted_accounts_get_request, + build_deleted_accounts_list_request, + build_deleted_accounts_purge_request, + build_deployments_create_or_update_request, + build_deployments_delete_request, + build_deployments_get_request, + build_deployments_list_request, + build_deployments_list_skus_request, + build_deployments_pause_request, + build_deployments_resume_request, + build_deployments_update_request, + build_encryption_scopes_create_or_update_request, + build_encryption_scopes_delete_request, + build_encryption_scopes_get_request, + build_encryption_scopes_list_request, + build_location_based_model_capacities_list_request, + build_managed_network_provisions_provision_managed_network_request, + build_managed_network_settings_get_request, + build_managed_network_settings_list_request, + build_managed_network_settings_patch_request, + build_managed_network_settings_put_request, + build_model_capacities_list_request, + build_models_list_request, + build_network_security_perimeter_configurations_get_request, + build_network_security_perimeter_configurations_list_request, + build_network_security_perimeter_configurations_reconcile_request, + build_operations_list_request, + build_outbound_rule_create_or_update_request, + build_outbound_rule_delete_request, + build_outbound_rule_get_request, + build_outbound_rule_list_request, + build_outbound_rules_post_request, + build_private_endpoint_connections_create_or_update_request, + build_private_endpoint_connections_delete_request, + build_private_endpoint_connections_get_request, + build_private_endpoint_connections_list_request, + build_private_link_resources_list_request, + build_project_capability_hosts_create_or_update_request, + build_project_capability_hosts_delete_request, + build_project_capability_hosts_get_request, + build_project_capability_hosts_list_request, + build_project_connections_create_request, + build_project_connections_delete_request, + build_project_connections_get_request, + build_project_connections_list_request, + build_project_connections_update_request, + build_projects_create_request, + build_projects_delete_request, + build_projects_get_request, + build_projects_list_request, + build_projects_update_request, + build_quota_tiers_create_or_update_request, + build_quota_tiers_get_request, + build_quota_tiers_list_by_subscription_request, + build_quota_tiers_update_request, + build_rai_blocklist_items_batch_add_request, + build_rai_blocklist_items_batch_delete_request, + build_rai_blocklist_items_create_or_update_request, + build_rai_blocklist_items_delete_request, + build_rai_blocklist_items_get_request, + build_rai_blocklist_items_list_request, + build_rai_blocklists_create_or_update_request, + build_rai_blocklists_delete_request, + build_rai_blocklists_get_request, + build_rai_blocklists_list_request, + build_rai_content_filters_get_request, + build_rai_content_filters_list_request, + build_rai_external_safety_provider_create_or_update_request, + build_rai_external_safety_provider_delete_request, + build_rai_external_safety_provider_get_request, + build_rai_external_safety_providers_list_request, + build_rai_policies_create_or_update_request, + build_rai_policies_delete_request, + build_rai_policies_get_request, + build_rai_policies_list_request, + build_rai_tool_labels_create_or_update_request, + build_rai_tool_labels_delete_request, + build_rai_tool_labels_get_request, + build_rai_tool_labels_list_request, + build_rai_topics_create_or_update_request, + build_rai_topics_delete_request, + build_rai_topics_get_request, + build_rai_topics_list_request, + build_resource_skus_list_request, + build_subscription_rai_policy_create_or_update_request, + build_subscription_rai_policy_delete_request, + build_subscription_rai_policy_get_request, + build_test_rai_external_safety_provider_create_or_update_request, + build_usages_list_request, +) from .._configuration import CognitiveServicesManagementClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -45,8 +206,6 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") @@ -60,15 +219,787 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """Lists all the available Cognitive Services account operations. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`accounts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: + """Returns a Cognitive Services account specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: Account. The Account is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Account + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + + _request = build_accounts_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Account, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(account, (IOBase, bytes)): + _content = account + else: + _content = json.dumps(account, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_accounts_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + account: _models.Account, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + account: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + account: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Is one of the following + types: Account, JSON, IO[bytes] Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + account=account, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Account, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Account].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(account, (IOBase, bytes)): + _content = account + else: + _content = json.dumps(account, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_accounts_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + account: _models.Account, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + account: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + account: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Is one of the following + types: Account, JSON, IO[bytes] Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + account=account, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Account, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Account].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_accounts_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes a Cognitive Services account from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Account"]: + """Returns all the resources of a particular type belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Account + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Account]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -81,12 +1012,19 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_accounts_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -101,16 +1039,24 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Account], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -123,9 +1069,19645 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Account"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of Account + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Account]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_accounts_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Account], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ApiKeys: + """Lists the account keys for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) + + _request = build_accounts_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiKeys, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.RegenerateKeyParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Is one of the following types: + RegenerateKeyParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.RegenerateKeyParameters or JSON or + IO[bytes] + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_accounts_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiKeys, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_skus( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.AccountSkuListResult: + """List available SKUs for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: AccountSkuListResult. The AccountSkuListResult is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AccountSkuListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AccountSkuListResult] = kwargs.pop("cls", None) + + _request = build_accounts_list_skus_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccountSkuListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_usages( + self, resource_group_name: str, account_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> _models.UsageListResult: + """Get usages for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :keyword filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :paramtype filter: str + :return: UsageListResult. The UsageListResult is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.UsageListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) + + _request = build_accounts_list_usages_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UsageListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_models( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AccountModel"]: + """List available Models for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of AccountModel + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AccountModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AccountModel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_accounts_list_models_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AccountModel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`deleted_accounts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: + """Returns a Cognitive Services account specified by the parameters. + + :param location: The location name. Required. + :type location: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: Account. The Account is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Account + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + + _request = build_deleted_accounts_get_request( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Account, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _purge_initial( + self, location: str, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deleted_accounts_purge_request( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_purge( + self, location: str, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Cognitive Services account from the resource group. + + :param location: The location name. Required. + :type location: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._purge_initial( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Account"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of Account + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Account]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deleted_accounts_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Account], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is one of the following types: + PrivateEndpointConnection, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified private endpoint connection associated with the Cognitive Services + account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionListResult: + """Gets the private endpoint connections associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: PrivateEndpointConnectionListResult. The PrivateEndpointConnectionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnectionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> _models.Deployment: + """Gets the specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.Deployment, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(deployment, (IOBase, bytes)): + _content = deployment + else: + _content = json.dumps(deployment, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_deployments_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: _models.Deployment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.Deployment, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Is one of the following types: Deployment, JSON, + IO[bytes] Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.Deployment or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + deployment=deployment, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Deployment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Deployment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Deployment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(deployment, (IOBase, bytes)): + _content = deployment + else: + _content = json.dumps(deployment, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_deployments_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: _models.PatchResourceTagsAndSku, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Is one of the following types: + PatchResourceTagsAndSku, JSON, IO[bytes] Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Deployment. The Deployment is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + deployment=deployment, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Deployment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Deployment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Deployment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deployments_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified deployment associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Deployment"]: + """Gets the deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of Deployment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Deployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_skus( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SkuResource"]: + """Lists the specified deployments skus associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: An iterator like instance of SkuResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.SkuResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SkuResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_skus_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SkuResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def pause( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> _models.Deployment: + """Pause a deployment. + + Pauses inferencing on a deployment by setting the deploymentState to 'Paused' (see + #/definitions/DeploymentProperties/properties/deploymentState). Only Standard, + DataZoneStandard, and GlobalStandard SKUs support this operation. Inference requests to the + paused deployment endpoint will receive HTTP 423 (Locked). This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_pause_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def resume( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> _models.Deployment: + """Resume a deployment. + + Resumes inferencing on a previously paused deployment by setting the deploymentState to + 'Running' (see #/definitions/DeploymentProperties/properties/deploymentState). This operation + is idempotent and can be safely called on already running deployments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_resume_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CommitmentPlansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`commitment_plans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> _models.CommitmentPlan: + """Gets the specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + _request = build_commitment_plans_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Is one of the following types: + CommitmentPlan, JSON, IO[bytes] Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or JSON or IO[bytes] + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(commitment_plan, (IOBase, bytes)): + _content = commitment_plan + else: + _content = json.dumps(commitment_plan, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_commitment_plans_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified commitmentPlan associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CommitmentPlan"]: + """Gets the commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of CommitmentPlan + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlan], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_plan( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> _models.CommitmentPlan: + """Returns a Cognitive Services commitment plan specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + _request = build_commitment_plans_get_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(commitment_plan, (IOBase, bytes)): + _content = commitment_plan + else: + _content = json.dumps(commitment_plan, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_create_or_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is one of + the following types: CommitmentPlan, JSON, IO[bytes] Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CommitmentPlan].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CommitmentPlan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(commitment_plan, (IOBase, bytes)): + _content = commitment_plan + else: + _content = json.dumps(commitment_plan, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.PatchResourceTagsAndSku, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is one of + the following types: PatchResourceTagsAndSku, JSON, IO[bytes] Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns CommitmentPlan. The CommitmentPlan is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CommitmentPlan].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CommitmentPlan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_plan_initial( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_commitment_plans_delete_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete_plan( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Cognitive Services commitment plan from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_plans_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of CommitmentPlan + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_plans_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlan], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_plans_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of CommitmentPlan + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_plans_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlan], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> _models.CommitmentPlanAccountAssociation: + """Gets the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :return: CommitmentPlanAccountAssociation. The CommitmentPlanAccountAssociation is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + + _request = build_commitment_plans_get_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlanAccountAssociation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_association_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(association, (IOBase, bytes)): + _content = association + else: + _content = json.dumps(association, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_create_or_update_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: _models.CommitmentPlanAccountAssociation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Is one of the following types: + CommitmentPlanAccountAssociation, JSON, IO[bytes] Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_association_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + association=association, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CommitmentPlanAccountAssociation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CommitmentPlanAccountAssociation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CommitmentPlanAccountAssociation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_association_initial( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_commitment_plans_delete_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_association_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_associations( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CommitmentPlanAccountAssociation"]: + """Gets the associations of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: An iterator like instance of CommitmentPlanAccountAssociation + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlanAccountAssociation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_associations_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlanAccountAssociation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`encryption_scopes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> _models.EncryptionScope: + """Gets the specified EncryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + _request = build_encryption_scopes_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EncryptionScope, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Required. + :type encryption_scope: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Required. + :type encryption_scope: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Required. + :type encryption_scope: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Is one of the following types: + EncryptionScope, JSON, IO[bytes] Required. + :type encryption_scope: ~azure.mgmt.cognitiveservices.models.EncryptionScope or JSON or + IO[bytes] + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(encryption_scope, (IOBase, bytes)): + _content = encryption_scope + else: + _content = json.dumps(encryption_scope, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_encryption_scopes_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EncryptionScope, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_encryption_scopes_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.EncryptionScope"]: + """Gets the content filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of EncryptionScope + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EncryptionScope]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_encryption_scopes_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EncryptionScope], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RaiPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, rai_policy_name: str, **kwargs: Any + ) -> _models.RaiPolicy: + """Gets the specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + _request = build_rai_policies_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: _models.RaiPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: Union[_models.RaiPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Is one of the following types: + RaiPolicy, JSON, IO[bytes] Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy or JSON or IO[bytes] + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_policy, (IOBase, bytes)): + _content = rai_policy + else: + _content = json.dumps(rai_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_policies_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, account_name: str, rai_policy_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_policies_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, rai_policy_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncItemPaged["_models.RaiPolicy"]: + """Gets the content filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiPolicy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_policies_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SubscriptionRaiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`subscription_rai_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, rai_policy_name: str, **kwargs: Any) -> _models.RaiPolicy: + """Gets the specified Content Filters associated with the Subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + _request = build_subscription_rai_policy_get_request( + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + rai_policy_name: str, + rai_policy: _models.RaiPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, rai_policy_name: str, rai_policy: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, rai_policy_name: str, rai_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, rai_policy_name: str, rai_policy: Union[_models.RaiPolicy, JSON, IO[bytes]], **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Is one of the following types: + RaiPolicy, JSON, IO[bytes] Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy or JSON or IO[bytes] + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_policy, (IOBase, bytes)): + _content = rai_policy + else: + _content = json.dumps(rai_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_subscription_rai_policy_create_or_update_request( + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial(self, rai_policy_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_subscription_rai_policy_delete_request( + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, rai_policy_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + rai_policy_name=rai_policy_name, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class RaiBlocklistItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_blocklist_items` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Gets the specified custom blocklist Item associated with the custom blocklist. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiBlocklistItem] = kwargs.pop("cls", None) + + _request = build_rai_blocklist_items_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklistItem, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: _models.RaiBlocklistItem, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Required. + :type rai_blocklist_item: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Required. + :type rai_blocklist_item: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Required. + :type rai_blocklist_item: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: Union[_models.RaiBlocklistItem, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Is one of the following + types: RaiBlocklistItem, JSON, IO[bytes] Required. + :type rai_blocklist_item: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem or JSON or + IO[bytes] + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiBlocklistItem] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist_item, (IOBase, bytes)): + _content = rai_blocklist_item + else: + _content = json.dumps(rai_blocklist_item, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklist_items_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklistItem, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_blocklist_items_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified blocklist Item associated with the custom blocklist. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RaiBlocklistItem"]: + """Gets the blocklist items associated with the custom blocklist. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :return: An iterator like instance of RaiBlocklistItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiBlocklistItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiBlocklistItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_blocklist_items_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiBlocklistItem], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: List[_models.RaiBlocklistItemBulkRequest], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Required. + :type rai_blocklist_items: + list[~azure.mgmt.cognitiveservices.models.RaiBlocklistItemBulkRequest] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: List[JSON], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Required. + :type rai_blocklist_items: list[JSON] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Required. + :type rai_blocklist_items: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: Union[List[_models.RaiBlocklistItemBulkRequest], List[JSON], IO[bytes]], + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Is one of the + following types: [RaiBlocklistItemBulkRequest], [JSON], IO[bytes] Required. + :type rai_blocklist_items: + list[~azure.mgmt.cognitiveservices.models.RaiBlocklistItemBulkRequest] or list[JSON] or + IO[bytes] + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiBlocklist] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist_items, (IOBase, bytes)): + _content = rai_blocklist_items + else: + _content = json.dumps(rai_blocklist_items, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklist_items_batch_add_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklist, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def batch_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items_names: List[str], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Batch operation to delete blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items_names: List of RAI Blocklist Items Names. Required. + :type rai_blocklist_items_names: list[str] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def batch_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items_names: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Batch operation to delete blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items_names: List of RAI Blocklist Items Names. Required. + :type rai_blocklist_items_names: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def batch_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items_names: Union[List[str], IO[bytes]], + **kwargs: Any + ) -> None: + """Batch operation to delete blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items_names: List of RAI Blocklist Items Names. Is either a [str] type or + a IO[bytes] type. Required. + :type rai_blocklist_items_names: list[str] or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist_items_names, (IOBase, bytes)): + _content = rai_blocklist_items_names + else: + _content = json.dumps(rai_blocklist_items_names, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklist_items_batch_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class RaiBlocklistsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_blocklists` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> _models.RaiBlocklist: + """Gets the specified custom blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiBlocklist] = kwargs.pop("cls", None) + + _request = build_rai_blocklists_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklist, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: _models.RaiBlocklist, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Required. + :type rai_blocklist: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Required. + :type rai_blocklist: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Required. + :type rai_blocklist: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: Union[_models.RaiBlocklist, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Is one of the following + types: RaiBlocklist, JSON, IO[bytes] Required. + :type rai_blocklist: ~azure.mgmt.cognitiveservices.models.RaiBlocklist or JSON or IO[bytes] + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiBlocklist] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist, (IOBase, bytes)): + _content = rai_blocklist + else: + _content = json.dumps(rai_blocklist, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklists_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklist, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_blocklists_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified custom blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RaiBlocklist"]: + """Gets the custom blocklists associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiBlocklist + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiBlocklist] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiBlocklist]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_blocklists_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiBlocklist], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RaiTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_topics` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, rai_topic_name: str, **kwargs: Any + ) -> _models.RaiTopic: + """Gets the specified custom topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiTopic] = kwargs.pop("cls", None) + + _request = build_rai_topics_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: _models.RaiTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Required. + :type rai_topic: ~azure.mgmt.cognitiveservices.models.RaiTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Required. + :type rai_topic: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Required. + :type rai_topic: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: Union[_models.RaiTopic, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Is one of the following types: RaiTopic, + JSON, IO[bytes] Required. + :type rai_topic: ~azure.mgmt.cognitiveservices.models.RaiTopic or JSON or IO[bytes] + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiTopic] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_topic, (IOBase, bytes)): + _content = rai_topic + else: + _content = json.dumps(rai_topic, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_topics_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, account_name: str, rai_topic_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_topics_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, rai_topic_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified custom topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncItemPaged["_models.RaiTopic"]: + """Gets the custom topics associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiTopic + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiTopic]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_topics_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiTopic], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RaiToolLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_tool_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, rai_tool_connection_name: str, **kwargs: Any + ) -> _models.RaiToolLabel: + """Gets the specified RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiToolLabel] = kwargs.pop("cls", None) + + _request = build_rai_tool_labels_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiToolLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: _models.RaiToolLabel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Required. + :type rai_tool_label: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Required. + :type rai_tool_label: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Required. + :type rai_tool_label: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: Union[_models.RaiToolLabel, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Is one of the following types: + RaiToolLabel, JSON, IO[bytes] Required. + :type rai_tool_label: ~azure.mgmt.cognitiveservices.models.RaiToolLabel or JSON or IO[bytes] + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiToolLabel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_tool_label, (IOBase, bytes)): + _content = rai_tool_label + else: + _content = json.dumps(rai_tool_label, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_tool_labels_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiToolLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, account_name: str, rai_tool_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_tool_labels_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, rai_tool_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RaiToolLabel"]: + """Lists all RAI Tool Labels associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiToolLabel + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiToolLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiToolLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_tool_labels_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiToolLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RaiContentFiltersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_content_filters` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, filter_name: str, **kwargs: Any) -> _models.RaiContentFilter: + """Get Content Filters by Name. + + :param location: The name of the Azure region. Required. + :type location: str + :param filter_name: The name of the RAI Content Filter. Required. + :type filter_name: str + :return: RaiContentFilter. The RaiContentFilter is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiContentFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiContentFilter] = kwargs.pop("cls", None) + + _request = build_rai_content_filters_get_request( + location=location, + filter_name=filter_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiContentFilter, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.RaiContentFilter"]: + """List Content Filters types. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of RaiContentFilter + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiContentFilter] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiContentFilter]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_content_filters_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiContentFilter], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NetworkSecurityPerimeterConfigurationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`network_security_perimeter_configurations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, nsp_configuration_name: str, **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets the specified NSP configurations for an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param nsp_configuration_name: The name of the NSP Configuration. Required. + :type nsp_configuration_name: str + :return: NetworkSecurityPerimeterConfiguration. The NetworkSecurityPerimeterConfiguration is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + nsp_configuration_name=nsp_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of NetworkSecurityPerimeterConfiguration + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_network_security_perimeter_configurations_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NetworkSecurityPerimeterConfiguration], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _reconcile_initial( + self, resource_group_name: str, account_name: str, nsp_configuration_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_reconcile_request( + resource_group_name=resource_group_name, + account_name=account_name, + nsp_configuration_name=nsp_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_reconcile( + self, resource_group_name: str, account_name: str, nsp_configuration_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkSecurityPerimeterConfiguration]: + """Reconcile the NSP configuration for an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param nsp_configuration_name: The name of the NSP Configuration. Required. + :type nsp_configuration_name: str + :return: An instance of AsyncLROPoller that returns NetworkSecurityPerimeterConfiguration. The + NetworkSecurityPerimeterConfiguration is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reconcile_initial( + resource_group_name=resource_group_name, + account_name=account_name, + nsp_configuration_name=nsp_configuration_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.NetworkSecurityPerimeterConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.NetworkSecurityPerimeterConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class DefenderForAISettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`defender_for_ai_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, defender_for_ai_setting_name: str, **kwargs: Any + ) -> _models.DefenderForAISetting: + """Gets the specified Defender for AI setting by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DefenderForAISetting] = kwargs.pop("cls", None) + + _request = build_defender_for_ai_settings_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + defender_for_ai_setting_name=defender_for_ai_setting_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DefenderForAISetting, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: _models.DefenderForAISetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: Union[_models.DefenderForAISetting, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Is one of + the following types: DefenderForAISetting, JSON, IO[bytes] Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting or + JSON or IO[bytes] + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForAISetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(defender_for_ai_settings, (IOBase, bytes)): + _content = defender_for_ai_settings + else: + _content = json.dumps(defender_for_ai_settings, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_defender_for_ai_settings_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + defender_for_ai_setting_name=defender_for_ai_setting_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DefenderForAISetting, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: _models.DefenderForAISetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: Union[_models.DefenderForAISetting, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Is one of + the following types: DefenderForAISetting, JSON, IO[bytes] Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting or + JSON or IO[bytes] + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForAISetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(defender_for_ai_settings, (IOBase, bytes)): + _content = defender_for_ai_settings + else: + _content = json.dumps(defender_for_ai_settings, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_defender_for_ai_settings_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + defender_for_ai_setting_name=defender_for_ai_setting_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DefenderForAISetting, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.DefenderForAISetting"]: + """Lists the Defender for AI settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of DefenderForAISetting + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.DefenderForAISetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DefenderForAISetting]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_defender_for_ai_settings_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DefenderForAISetting], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`projects` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> _models.Project: + """Returns a Cognitive Services project specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :return: Project. The Project is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Project + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + + _request = build_projects_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Project, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(project, (IOBase, bytes)): + _content = project + else: + _content = json.dumps(project, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_projects_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Is one of the following + types: Project, JSON, IO[bytes] Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + project=project, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Project, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Project].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Project]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(project, (IOBase, bytes)): + _content = project + else: + _content = json.dumps(project, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_projects_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Is one of the following + types: Project, JSON, IO[bytes] Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + project=project, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Project, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Project].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Project]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_projects_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a Cognitive Services project from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Project"]: + """Returns all the projects in a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of Project + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Project]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_projects_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Project], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProjectConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`project_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, project_name: str, connection_name: str, **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Lists Cognitive Services project connection by name. + + Lists Cognitive Services project connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + _request = build_project_connections_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[_models.ConnectionPropertiesV2BasicResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionPropertiesV2BasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Is one of the + following types: ConnectionPropertiesV2BasicResource, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource or + JSON or IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_project_connections_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[_models.ConnectionUpdateContent] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionUpdateContent, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Is one of the following types: + ConnectionUpdateContent, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent or JSON or + IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_project_connections_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, account_name: str, project_name: str, connection_name: str, **kwargs: Any + ) -> None: + """Delete Cognitive Services project connection by name. + + Delete Cognitive Services project connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_project_connections_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + project_name: str, + *, + target: Optional[str] = None, + category: Optional[str] = None, + include_all: bool = False, + **kwargs: Any + ) -> AsyncItemPaged["_models.ConnectionPropertiesV2BasicResource"]: + """Lists all the available Cognitive Services project connections under the specified project. + + Lists all the available Cognitive Services project connections under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :keyword target: Target of the connection. Default value is None. + :paramtype target: str + :keyword category: Category of the connection. Default value is None. + :paramtype category: str + :keyword include_all: query parameter that indicates if get connection call should return both + connections and datastores. Default value is False. + :paramtype include_all: bool + :return: An iterator like instance of ConnectionPropertiesV2BasicResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ConnectionPropertiesV2BasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_project_connections_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + target=target, + category=category, + include_all=include_all, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ConnectionPropertiesV2BasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProjectCapabilityHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`project_capability_hosts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, project_name: str, capability_host_name: str, **kwargs: Any + ) -> _models.ProjectCapabilityHost: + """Get project capabilityHost. + + Get project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: ProjectCapabilityHost. The ProjectCapabilityHost is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProjectCapabilityHost] = kwargs.pop("cls", None) + + _request = build_project_capability_hosts_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProjectCapabilityHost, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: Union[_models.ProjectCapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(capability_host, (IOBase, bytes)): + _content = capability_host + else: + _content = json.dumps(capability_host, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_project_capability_hosts_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: _models.ProjectCapabilityHost, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ProjectCapabilityHost. The + ProjectCapabilityHost is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ProjectCapabilityHost. The + ProjectCapabilityHost is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ProjectCapabilityHost. The + ProjectCapabilityHost is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: Union[_models.ProjectCapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Is one of the following types: + ProjectCapabilityHost, JSON, IO[bytes] Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ProjectCapabilityHost. The + ProjectCapabilityHost is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProjectCapabilityHost] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + capability_host=capability_host, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ProjectCapabilityHost, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ProjectCapabilityHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ProjectCapabilityHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, project_name: str, capability_host_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_project_capability_hosts_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, project_name: str, capability_host_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete project capabilityHost. + + Delete project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ProjectCapabilityHost"]: + """List capabilityHost. + + List capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :return: An iterator like instance of ProjectCapabilityHost + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProjectCapabilityHost]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_project_capability_hosts_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProjectCapabilityHost], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class QuotaTiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`quota_tiers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, default: str, **kwargs: Any) -> _models.QuotaTier: + """Gets the Quota Tier for a subscription. + + Gets the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.QuotaTier] = kwargs.pop("cls", None) + + _request = build_quota_tiers_get_request( + default=default, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaTier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, default: str, tier: _models.QuotaTier, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, default: str, tier: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, default: str, tier: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, default: str, tier: Union[_models.QuotaTier, JSON, IO[bytes]], **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Is one of the following + types: QuotaTier, JSON, IO[bytes] Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier or JSON or IO[bytes] + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaTier] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(tier, (IOBase, bytes)): + _content = tier + else: + _content = json.dumps(tier, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_tiers_create_or_update_request( + default=default, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaTier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, default: str, tier: _models.QuotaTier, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, default: str, tier: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, default: str, tier: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, default: str, tier: Union[_models.QuotaTier, JSON, IO[bytes]], **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Is one of the following + types: QuotaTier, JSON, IO[bytes] Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier or JSON or IO[bytes] + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaTier] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(tier, (IOBase, bytes)): + _content = tier + else: + _content = json.dumps(tier, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_tiers_update_request( + default=default, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaTier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.QuotaTier"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of QuotaTier + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.QuotaTier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.QuotaTier]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_quota_tiers_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.QuotaTier], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AgentApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`agent_applications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> _models.AgentApplication: + """Gets an Agent Application by name. + + Gets an Agent Application by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: AgentApplication. The AgentApplication is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AgentApplication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AgentApplication] = kwargs.pop("cls", None) + + _request = build_agent_applications_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentApplication, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: Union[_models.AgentApplication, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_applications_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: _models.AgentApplication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentApplication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: Union[_models.AgentApplication, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Is one of the following types: + AgentApplication, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentApplication or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentApplication] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AgentApplication, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AgentApplication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AgentApplication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_applications_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete Agent Application. + + Delete Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + project_name: str, + *, + count: int = 30, + skip: Optional[int] = None, + skip_token: Optional[str] = None, + names: Optional[List[str]] = None, + search_text: Optional[str] = None, + order_by: Optional[str] = None, + order_by_asc: bool = False, + **kwargs: Any + ) -> AsyncItemPaged["_models.AgentApplication"]: + """Lists Agent Applications in the project. + + Lists Agent Applications in the project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :keyword count: Number of agent applications to be retrieved in a page of results. Default + value is 30. + :paramtype count: int + :keyword skip: Number of agent applications to skip. Default value is None. + :paramtype skip: int + :keyword skip_token: Continuation token for pagination. Default value is None. + :paramtype skip_token: str + :keyword names: Names of agent applications to retrieve. Default value is None. + :paramtype names: list[str] + :keyword search_text: Search text for filtering agent applications. Default value is None. + :paramtype search_text: str + :keyword order_by: Field to order by. Default value is None. + :paramtype order_by: str + :keyword order_by_asc: Whether to order in ascending order. Default value is False. + :paramtype order_by_asc: bool + :return: An iterator like instance of AgentApplication + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentApplication]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_agent_applications_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + count=count, + skip=skip, + skip_token=skip_token, + names=names, + search_text=search_text, + order_by=order_by, + order_by_asc=order_by_asc, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentApplication], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_agents( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> _models.AgentReferenceResourceArmPaginatedResult: + """Lists agents for an Agent Application. + + Lists agents for an Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: AgentReferenceResourceArmPaginatedResult. The AgentReferenceResourceArmPaginatedResult + is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AgentReferenceResourceArmPaginatedResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AgentReferenceResourceArmPaginatedResult] = kwargs.pop("cls", None) + + _request = build_agent_applications_list_agents_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentReferenceResourceArmPaginatedResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def enable( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> None: + """Enables an Agent Application. + + Enables an Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_applications_enable_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def disable( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> None: + """Disables an Agent Application. + + Disables an Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_applications_disable_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ComputesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`computes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, compute_name: str, **kwargs: Any + ) -> _models.Compute: + """Gets the specified compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :return: Compute. The Compute is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Compute + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Compute] = kwargs.pop("cls", None) + + _request = build_computes_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Compute, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: Union[_models.Compute, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_computes_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: _models.Compute, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Required. + :type resource: ~azure.mgmt.cognitiveservices.models.Compute + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: Union[_models.Compute, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Is one of the following types: Compute, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.cognitiveservices.models.Compute or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Compute] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Compute, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Compute].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Compute]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: Union[_models.ComputePatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_computes_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: _models.ComputePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Required. + :type properties: ~azure.mgmt.cognitiveservices.models.ComputePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: Union[_models.ComputePatch, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Is one of the following types: ComputePatch, JSON, + IO[bytes] Required. + :type properties: ~azure.mgmt.cognitiveservices.models.ComputePatch or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Compute] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Compute, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Compute].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Compute]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, compute_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_computes_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, compute_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Compute"]: + """Gets the computes associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of Compute + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Compute]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_computes_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Compute], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_link_resources_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class TestRaiExternalSafetyProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`test_rai_external_safety_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: _models.RaiExternalSafetyProviderSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: Union[_models.RaiExternalSafetyProviderSchema, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Is one of the + following types: RaiExternalSafetyProviderSchema, JSON, IO[bytes] Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + JSON or IO[bytes] + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiExternalSafetyProviderSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(safety_provider, (IOBase, bytes)): + _content = safety_provider + else: + _content = json.dumps(safety_provider, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_test_rai_external_safety_provider_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProviderSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ManagedNetworkProvisionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`managed_network_provisions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _provision_managed_network_initial( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ManagedNetworkProvisionOptions, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_managed_network_provisions_provision_managed_network_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[_models.ManagedNetworkProvisionOptions] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Default + value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionOptions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Default + value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Default + value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ManagedNetworkProvisionOptions, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Is one of + the following types: ManagedNetworkProvisionOptions, JSON, IO[bytes] Default value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionOptions or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.ManagedNetworkProvisionStatus] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._provision_managed_network_initial( + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedNetworkProvisionStatus, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedNetworkProvisionStatus].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedNetworkProvisionStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class RaiExternalSafetyProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_external_safety_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, safety_provider_name: str, **kwargs: Any) -> _models.RaiExternalSafetyProviderSchema: + """Gets the specified external safety provider associated with the Subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiExternalSafetyProviderSchema] = kwargs.pop("cls", None) + + _request = build_rai_external_safety_provider_get_request( + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProviderSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update( + self, + safety_provider_name: str, + safety_provider: _models.RaiExternalSafetyProviderSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, safety_provider_name: str, safety_provider: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + safety_provider_name: str, + safety_provider: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + safety_provider_name: str, + safety_provider: Union[_models.RaiExternalSafetyProviderSchema, JSON, IO[bytes]], + **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Is one of the + following types: RaiExternalSafetyProviderSchema, JSON, IO[bytes] Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + JSON or IO[bytes] + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]] = kwargs.pop( + "cls", None + ) + + content_type = content_type or "application/json" + _content = None + if isinstance(safety_provider, (IOBase, bytes)): + _content = safety_provider + else: + _content = json.dumps(safety_provider, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_external_safety_provider_create_or_update_request( + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProviderSchema, response.json()) + + if response.status_code == 201: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProvider, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial(self, safety_provider_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_external_safety_provider_delete_request( + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, safety_provider_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes the specified custom topic associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + safety_provider_name=safety_provider_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class RaiExternalSafetyProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`rai_external_safety_providers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.RaiExternalSafetyProviderSchema"]: + """Gets the safety providers associated with the subscription. + + :return: An iterator like instance of RaiExternalSafetyProviderSchema + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiExternalSafetyProviderSchema]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_external_safety_providers_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiExternalSafetyProviderSchema], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AccountConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`account_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, connection_name: str, **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Lists Cognitive Services account connection by name. + + Lists Cognitive Services account connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + _request = build_account_connections_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[_models.ConnectionPropertiesV2BasicResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionPropertiesV2BasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Is one of the + following types: ConnectionPropertiesV2BasicResource, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource or + JSON or IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_account_connections_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[_models.ConnectionUpdateContent] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionUpdateContent, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Is one of the following types: + ConnectionUpdateContent, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent or JSON or + IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_account_connections_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, resource_group_name: str, account_name: str, connection_name: str, **kwargs: Any) -> None: + """Delete Cognitive Services account connection by name. + + Delete Cognitive Services account connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_account_connections_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + *, + target: Optional[str] = None, + category: Optional[str] = None, + include_all: bool = False, + **kwargs: Any + ) -> AsyncItemPaged["_models.ConnectionPropertiesV2BasicResource"]: + """Lists all the available Cognitive Services account connections under the specified account. + + Lists all the available Cognitive Services account connections under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :keyword target: Target of the connection. Default value is None. + :paramtype target: str + :keyword category: Category of the connection. Default value is None. + :paramtype category: str + :keyword include_all: query parameter that indicates if get connection call should return both + connections and datastores. Default value is False. + :paramtype include_all: bool + :return: An iterator like instance of ConnectionPropertiesV2BasicResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ConnectionPropertiesV2BasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_account_connections_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + target=target, + category=category, + include_all=include_all, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ConnectionPropertiesV2BasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AccountCapabilityHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`account_capability_hosts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, capability_host_name: str, **kwargs: Any + ) -> _models.CapabilityHost: + """Get account capabilityHost. + + Get account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: CapabilityHost. The CapabilityHost is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CapabilityHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CapabilityHost] = kwargs.pop("cls", None) + + _request = build_account_capability_hosts_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CapabilityHost, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: Union[_models.CapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(capability_host, (IOBase, bytes)): + _content = capability_host + else: + _content = json.dumps(capability_host, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_account_capability_hosts_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: _models.CapabilityHost, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.CapabilityHost + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CapabilityHost. The CapabilityHost is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CapabilityHost. The CapabilityHost is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CapabilityHost. The CapabilityHost is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: Union[_models.CapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Is one of the following types: + CapabilityHost, JSON, IO[bytes] Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.CapabilityHost or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CapabilityHost. The CapabilityHost is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapabilityHost] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + capability_host=capability_host, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CapabilityHost, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CapabilityHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CapabilityHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, capability_host_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_account_capability_hosts_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, capability_host_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete account capabilityHost. + + Delete account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CapabilityHost"]: + """List capabilityHost. + + List capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of CapabilityHost + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapabilityHost]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_account_capability_hosts_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CapabilityHost], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OutboundRuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`outbound_rule` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, managed_network_name: str, rule_name: str, **kwargs: Any + ) -> _models.OutboundRuleBasicResource: + """The GET API for retrieving a single outbound rule of the managed network associated with the + cognitive services account. + + The GET API for retrieving a single outbound rule of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :return: OutboundRuleBasicResource. The OutboundRuleBasicResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OutboundRuleBasicResource] = kwargs.pop("cls", None) + + _request = build_outbound_rule_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OutboundRuleBasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: Union[_models.OutboundRuleBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_outbound_rule_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: _models.OutboundRuleBasicResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Required. + :type body: ~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: Union[_models.OutboundRuleBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Is one of the following types: OutboundRuleBasicResource, JSON, IO[bytes] + Required. + :type body: ~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OutboundRuleBasicResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OutboundRuleBasicResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OutboundRuleBasicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OutboundRuleBasicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, account_name: str, managed_network_name: str, rule_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_outbound_rule_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, managed_network_name: str, rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """The DELETE API for deleting a single outbound rule of the managed network associated with the + cognitive services account. + + The DELETE API for deleting a single outbound rule of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, managed_network_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.OutboundRuleBasicResource"]: + """The GET API for retrieving the list of outbound rules of the managed network associated with + the cognitive services account. + + The GET API for retrieving the list of outbound rules of the managed network associated with + the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :return: An iterator like instance of OutboundRuleBasicResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OutboundRuleBasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_outbound_rule_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OutboundRuleBasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedNetworkSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`managed_network_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, managed_network_name: str, **kwargs: Any + ) -> _models.ManagedNetworkSettingsPropertiesBasicResource: + """Get API for managed network settings of a cognitive services account. + + Get API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :return: ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedNetworkSettingsPropertiesBasicResource] = kwargs.pop("cls", None) + + _request = build_managed_network_settings_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedNetworkSettingsPropertiesBasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _put_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_network_settings_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: _models.ManagedNetworkSettingsPropertiesBasicResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Is one of the following types: + ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedNetworkSettingsPropertiesBasicResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._put_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedNetworkSettingsPropertiesBasicResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _patch_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_managed_network_settings_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[_models.ManagedNetworkSettingsPropertiesBasicResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Default value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Is one of the following types: + ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes] Default value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns + ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.ManagedNetworkSettingsPropertiesBasicResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._patch_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedNetworkSettingsPropertiesBasicResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ManagedNetworkSettingsPropertiesBasicResource"]: + """List API for managed network settings of a cognitive services account. + + List API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of ManagedNetworkSettingsPropertiesBasicResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedNetworkSettingsPropertiesBasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_network_settings_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedNetworkSettingsPropertiesBasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OutboundRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`outbound_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _post_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_outbound_rules_post_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: _models.ManagedNetworkSettingsBasicResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Is one of the following types: + ManagedNetworkSettingsBasicResource, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsBasicResource or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OutboundRuleListResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._post_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.OutboundRuleListResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OutboundRuleListResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OutboundRuleListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class AgentDeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`agent_deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> _models.AgentDeployment: + """Gets an Agent Deployment by name. + + Gets an Agent Deployment by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: AgentDeployment. The AgentDeployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AgentDeployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AgentDeployment] = kwargs.pop("cls", None) + + _request = build_agent_deployments_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentDeployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: Union[_models.AgentDeployment, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_deployments_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: _models.AgentDeployment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: Union[_models.AgentDeployment, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Is one of the following types: + AgentDeployment, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentDeployment or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentDeployment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AgentDeployment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AgentDeployment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AgentDeployment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_deployments_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete Agent Deployment. + + Delete Agent Deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + *, + count: int = 30, + skip_token: Optional[str] = None, + names: Optional[List[str]] = None, + order_by: Optional[str] = None, + order_by_asc: bool = False, + **kwargs: Any + ) -> AsyncItemPaged["_models.AgentDeployment"]: + """Lists Agent Deployments in the application. + + Lists Agent Deployments in the application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :keyword count: Number of agent deployments to be retrieved in a page of results. Default value + is 30. + :paramtype count: int + :keyword skip_token: Continuation token for pagination. Default value is None. + :paramtype skip_token: str + :keyword names: Names of agent deployments to retrieve. Default value is None. + :paramtype names: list[str] + :keyword order_by: Field to order by. Default value is None. + :paramtype order_by: str + :keyword order_by_asc: Whether to order in ascending order. Default value is False. + :paramtype order_by_asc: bool + :return: An iterator like instance of AgentDeployment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentDeployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_agent_deployments_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + count=count, + skip_token=skip_token, + names=names, + order_by=order_by, + order_by_asc=order_by_asc, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def start( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: + """Starts an Agent Deployment. + + Starts an Agent Deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_deployments_start_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def stop( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: + """Stops an Agent Deployment. + + Stops an Agent Deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_deployments_stop_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ResourceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`resource_skus` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.ResourceSku"]: + """Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + + :return: An iterator like instance of ResourceSku + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceSku]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_resource_skus_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceSku], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, *, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Usage"]: + """Get usages for the requested subscription. + + :param location: The location name. Required. + :type location: str + :keyword filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :paramtype filter: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_usages_list_request( + location=location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CommitmentTiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`commitment_tiers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.CommitmentTier"]: + """List Commitment Tiers. + + :param location: The location name. Required. + :type location: str + :return: An iterator like instance of CommitmentTier + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentTier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentTier]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_tiers_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentTier], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ModelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`models` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> AsyncItemPaged["_models.Model"]: + """List Models. + + :param location: The location name. Required. + :type location: str + :return: An iterator like instance of Model + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.Model] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Model]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_models_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Model], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class LocationBasedModelCapacitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`location_based_model_capacities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, location: str, *, model_format: str, model_name: str, model_version: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ModelCapacityListResultValueItem"]: + """List Location Based ModelCapacities. + + :param location: The location name. Required. + :type location: str + :keyword model_format: The format of the Model. Required. + :paramtype model_format: str + :keyword model_name: The name of the Model. Required. + :paramtype model_name: str + :keyword model_version: The version of the Model. Required. + :paramtype model_version: str + :return: An iterator like instance of ModelCapacityListResultValueItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ModelCapacityListResultValueItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ModelCapacityListResultValueItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_location_based_model_capacities_list_request( + location=location, + subscription_id=self._config.subscription_id, + model_format=model_format, + model_name=model_name, + model_version=model_version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ModelCapacityListResultValueItem], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ModelCapacitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.aio.CognitiveServicesManagementClient`'s + :attr:`model_capacities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, *, model_format: str, model_name: str, model_version: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ModelCapacityListResultValueItem"]: + """List ModelCapacities. + + :keyword model_format: The format of the Model. Required. + :paramtype model_format: str + :keyword model_name: The name of the Model. Required. + :paramtype model_name: str + :keyword model_version: The version of the Model. Required. + :paramtype model_version: str + :return: An iterator like instance of ModelCapacityListResultValueItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cognitiveservices.models.ModelCapacityListResultValueItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ModelCapacityListResultValueItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_model_capacities_list_request( + subscription_id=self._config.subscription_id, + model_format=model_format, + model_name=model_name, + model_version=model_version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ModelCapacityListResultValueItem], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class _CognitiveServicesManagementClientOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], CognitiveServicesManagementClientConfiguration] +): + + @overload + async def check_sku_availability( + self, + location: str, + parameters: _models.CheckSkuAvailabilityParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_sku_availability( + self, location: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_sku_availability( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_sku_availability( + self, location: str, parameters: Union[_models.CheckSkuAvailabilityParameter, JSON, IO[bytes]], **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Is one of the following types: + CheckSkuAvailabilityParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityParameter or JSON or + IO[bytes] + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SkuAvailabilityListResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cognitive_services_management_check_sku_availability_request( + location=location, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SkuAvailabilityListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_domain_availability( + self, + parameters: _models.CheckDomainAvailabilityParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_domain_availability( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_domain_availability( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_domain_availability( + self, parameters: Union[_models.CheckDomainAvailabilityParameter, JSON, IO[bytes]], **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Is one of the following types: + CheckDomainAvailabilityParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityParameter or JSON + or IO[bytes] + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DomainAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cognitive_services_management_check_domain_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DomainAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def calculate_model_capacity( + self, + parameters: _models.CalculateModelCapacityParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def calculate_model_capacity( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def calculate_model_capacity( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def calculate_model_capacity( + self, parameters: Union[_models.CalculateModelCapacityParameter, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Is one of the following types: + CalculateModelCapacityParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityParameter or JSON + or IO[bytes] + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CalculateModelCapacityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cognitive_services_management_calculate_model_capacity_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CalculateModelCapacityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py index bd306314b8f1..9d85a6aecc60 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,22 +13,30 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore AADAuthTypeConnectionProperties, AbusePenalty, AccessKeyAuthTypeConnectionProperties, Account, AccountKeyAuthTypeConnectionProperties, - AccountListResult, AccountModel, - AccountModelListResult, AccountProperties, AccountSku, AccountSkuListResult, + AgentApplication, + AgentDeployment, + AgentDeploymentProperties, + AgentProtocolVersion, + AgentReference, + AgentReferenceProperties, + AgentReferenceResourceArmPaginatedResult, + AgenticApplicationProperties, ApiKeyAuthConnectionProperties, ApiKeys, ApiProperties, - AzureEntityResource, + ApplicationAuthorizationPolicy, + ApplicationTrafficRoutingPolicy, + AssignedIdentity, BillingMeterInfo, CalculateModelCapacityParameter, CalculateModelCapacityResult, @@ -37,19 +45,21 @@ CapabilityHost, CapabilityHostProperties, CapacityConfig, + ChannelsBuiltInAuthorizationPolicy, CheckDomainAvailabilityParameter, CheckSkuAvailabilityParameter, CommitmentCost, CommitmentPeriod, CommitmentPlan, CommitmentPlanAccountAssociation, - CommitmentPlanAccountAssociationListResult, + CommitmentPlanAccountAssociationProperties, CommitmentPlanAssociation, - CommitmentPlanListResult, CommitmentPlanProperties, CommitmentQuota, CommitmentTier, - CommitmentTierListResult, + Compute, + ComputePatch, + ComputeProperties, ConnectionAccessKey, ConnectionAccountKey, ConnectionApiKey, @@ -58,7 +68,6 @@ ConnectionPersonalAccessToken, ConnectionPropertiesV2, ConnectionPropertiesV2BasicResource, - ConnectionPropertiesV2BasicResourceArmPaginatedResult, ConnectionServicePrincipal, ConnectionSharedAccessSignature, ConnectionUpdateContent, @@ -68,36 +77,39 @@ CustomKeysConnectionProperties, CustomTopicConfig, DefenderForAISetting, - DefenderForAISettingResult, + DefenderForAISettingProperties, Deployment, DeploymentCapacitySettings, - DeploymentListResult, DeploymentModel, DeploymentProperties, DeploymentScaleSettings, - DeploymentSkuListResult, DomainAvailability, Encryption, EncryptionScope, - EncryptionScopeListResult, EncryptionScopeProperties, ErrorAdditionalInfo, ErrorDetail, - ErrorDetailAutoGenerated, ErrorResponse, - ErrorResponseAutoGenerated, + FqdnOutboundRule, + HostedAgentDeployment, Identity, IpRule, KeyVaultProperties, + ManagedAgentDeployment, ManagedIdentityAuthTypeConnectionProperties, + ManagedNetworkProvisionOptions, + ManagedNetworkProvisionStatus, + ManagedNetworkSettings, + ManagedNetworkSettingsBasicResource, + ManagedNetworkSettingsEx, + ManagedNetworkSettingsProperties, + ManagedNetworkSettingsPropertiesBasicResource, MetricName, Model, ModelCapacityCalculatorWorkload, ModelCapacityCalculatorWorkloadRequestParam, - ModelCapacityListResult, ModelCapacityListResultValueItem, ModelDeprecationInfo, - ModelListResult, ModelSku, ModelSkuCapacityProperties, MultiRegionSettings, @@ -109,17 +121,20 @@ NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem, NetworkSecurityPerimeterConfiguration, NetworkSecurityPerimeterConfigurationAssociationInfo, - NetworkSecurityPerimeterConfigurationList, NetworkSecurityPerimeterConfigurationProperties, NetworkSecurityPerimeterProfileInfo, NoneAuthTypeConnectionProperties, OAuth2AuthTypeConnectionProperties, Operation, OperationDisplay, - OperationListResult, + OrganizationSharedBuiltInAuthorizationPolicy, + OutboundRule, + OutboundRuleBasicResource, + OutboundRuleListResult, PATAuthTypeConnectionProperties, PatchResourceTags, PatchResourceTagsAndSku, + Pool, PrivateEndpoint, PrivateEndpointConnection, PrivateEndpointConnectionListResult, @@ -129,18 +144,16 @@ PrivateLinkResourceProperties, PrivateLinkServiceConnectionState, Project, - ProjectListResult, + ProjectCapabilityHost, + ProjectCapabilityHostProperties, ProjectProperties, ProvisioningIssue, ProvisioningIssueProperties, ProxyResource, QuotaLimit, QuotaTier, - QuotaTierListResult, QuotaTierProperties, QuotaTierUpgradeEligibilityInfo, - RaiBlockListItemsResult, - RaiBlockListResult, RaiBlocklist, RaiBlocklistConfig, RaiBlocklistItem, @@ -148,17 +161,23 @@ RaiBlocklistItemProperties, RaiBlocklistProperties, RaiContentFilter, - RaiContentFilterListResult, RaiContentFilterProperties, + RaiExternalSafetyProvider, + RaiExternalSafetyProviderProperties, + RaiExternalSafetyProviderSchema, + RaiExternalSafetyProviderSchemaProperties, RaiMonitorConfig, RaiPolicy, RaiPolicyContentFilter, - RaiPolicyListResult, RaiPolicyProperties, + RaiSafetyProviderConfig, + RaiToolLabel, + RaiToolLabelProperties, + RaiToolLabelPropertiesAccountScope, + RaiToolLabelPropertiesProjectScopesItem, RaiTopic, RaiTopicConfig, RaiTopicProperties, - RaiTopicResult, RegenerateKeyParameters, RegionSetting, ReplacementConfig, @@ -166,10 +185,12 @@ Resource, ResourceBase, ResourceSku, - ResourceSkuListResult, ResourceSkuRestrictionInfo, ResourceSkuRestrictions, + RoleBasedBuiltInAuthorizationPolicy, + RootError, SASAuthTypeConnectionProperties, + SafetyProviderConfig, ServicePrincipalAuthTypeConnectionProperties, Sku, SkuAvailability, @@ -179,22 +200,31 @@ SkuResource, SystemData, ThrottlingRule, + TrafficRoutingRule, Usage, UsageListResult, UserAssignedIdentity, UserOwnedAmlWorkspace, UserOwnedStorage, UsernamePasswordAuthTypeConnectionProperties, + VersionedAgentReference, VirtualNetworkRule, ) -from ._cognitive_services_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore AbusePenaltyAction, ActionType, + AgentDeploymentProvisioningState, + AgentDeploymentState, + AgentDeploymentType, + AgentProtocol, + AgenticApplicationProvisioningState, + BuiltInAuthorizationScheme, ByPassSelection, CapabilityHostKind, CapabilityHostProvisioningState, CommitmentPlanProvisioningState, + ComputeProvisioningState, ConnectionAuthType, ConnectionCategory, ConnectionGroup, @@ -204,12 +234,21 @@ DeploymentModelVersionUpgradeOption, DeploymentProvisioningState, DeploymentScaleType, + DeploymentState, DeprecationStatus, EncryptionScopeProvisioningState, EncryptionScopeState, + FirewallSku, HostingModel, + IdentityKind, + IdentityManagementType, + IdentityProvisioningState, + IsolationMode, KeyName, KeySource, + ManagedNetworkKind, + ManagedNetworkProvisioningState, + ManagedNetworkStatus, ManagedPERequirement, ManagedPEStatus, ModelLifecycleStatus, @@ -221,6 +260,7 @@ ProvisioningState, PublicNetworkAccess, QuotaUsageStatus, + RaiActionType, RaiPolicyContentSource, RaiPolicyMode, RaiPolicyType, @@ -228,11 +268,17 @@ ResourceSkuRestrictionsReasonCode, ResourceSkuRestrictionsType, RoutingMethods, + RuleCategory, + RuleStatus, + RuleType, ScenarioType, + ServiceTier, SkuTier, TierUpgradePolicy, + TrafficRoutingProtocol, UnitType, UpgradeAvailabilityStatus, + VmPriority, ) from ._patch import __all__ as _patch_all from ._patch import * @@ -244,16 +290,24 @@ "AccessKeyAuthTypeConnectionProperties", "Account", "AccountKeyAuthTypeConnectionProperties", - "AccountListResult", "AccountModel", - "AccountModelListResult", "AccountProperties", "AccountSku", "AccountSkuListResult", + "AgentApplication", + "AgentDeployment", + "AgentDeploymentProperties", + "AgentProtocolVersion", + "AgentReference", + "AgentReferenceProperties", + "AgentReferenceResourceArmPaginatedResult", + "AgenticApplicationProperties", "ApiKeyAuthConnectionProperties", "ApiKeys", "ApiProperties", - "AzureEntityResource", + "ApplicationAuthorizationPolicy", + "ApplicationTrafficRoutingPolicy", + "AssignedIdentity", "BillingMeterInfo", "CalculateModelCapacityParameter", "CalculateModelCapacityResult", @@ -262,19 +316,21 @@ "CapabilityHost", "CapabilityHostProperties", "CapacityConfig", + "ChannelsBuiltInAuthorizationPolicy", "CheckDomainAvailabilityParameter", "CheckSkuAvailabilityParameter", "CommitmentCost", "CommitmentPeriod", "CommitmentPlan", "CommitmentPlanAccountAssociation", - "CommitmentPlanAccountAssociationListResult", + "CommitmentPlanAccountAssociationProperties", "CommitmentPlanAssociation", - "CommitmentPlanListResult", "CommitmentPlanProperties", "CommitmentQuota", "CommitmentTier", - "CommitmentTierListResult", + "Compute", + "ComputePatch", + "ComputeProperties", "ConnectionAccessKey", "ConnectionAccountKey", "ConnectionApiKey", @@ -283,7 +339,6 @@ "ConnectionPersonalAccessToken", "ConnectionPropertiesV2", "ConnectionPropertiesV2BasicResource", - "ConnectionPropertiesV2BasicResourceArmPaginatedResult", "ConnectionServicePrincipal", "ConnectionSharedAccessSignature", "ConnectionUpdateContent", @@ -293,36 +348,39 @@ "CustomKeysConnectionProperties", "CustomTopicConfig", "DefenderForAISetting", - "DefenderForAISettingResult", + "DefenderForAISettingProperties", "Deployment", "DeploymentCapacitySettings", - "DeploymentListResult", "DeploymentModel", "DeploymentProperties", "DeploymentScaleSettings", - "DeploymentSkuListResult", "DomainAvailability", "Encryption", "EncryptionScope", - "EncryptionScopeListResult", "EncryptionScopeProperties", "ErrorAdditionalInfo", "ErrorDetail", - "ErrorDetailAutoGenerated", "ErrorResponse", - "ErrorResponseAutoGenerated", + "FqdnOutboundRule", + "HostedAgentDeployment", "Identity", "IpRule", "KeyVaultProperties", + "ManagedAgentDeployment", "ManagedIdentityAuthTypeConnectionProperties", + "ManagedNetworkProvisionOptions", + "ManagedNetworkProvisionStatus", + "ManagedNetworkSettings", + "ManagedNetworkSettingsBasicResource", + "ManagedNetworkSettingsEx", + "ManagedNetworkSettingsProperties", + "ManagedNetworkSettingsPropertiesBasicResource", "MetricName", "Model", "ModelCapacityCalculatorWorkload", "ModelCapacityCalculatorWorkloadRequestParam", - "ModelCapacityListResult", "ModelCapacityListResultValueItem", "ModelDeprecationInfo", - "ModelListResult", "ModelSku", "ModelSkuCapacityProperties", "MultiRegionSettings", @@ -334,17 +392,20 @@ "NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem", "NetworkSecurityPerimeterConfiguration", "NetworkSecurityPerimeterConfigurationAssociationInfo", - "NetworkSecurityPerimeterConfigurationList", "NetworkSecurityPerimeterConfigurationProperties", "NetworkSecurityPerimeterProfileInfo", "NoneAuthTypeConnectionProperties", "OAuth2AuthTypeConnectionProperties", "Operation", "OperationDisplay", - "OperationListResult", + "OrganizationSharedBuiltInAuthorizationPolicy", + "OutboundRule", + "OutboundRuleBasicResource", + "OutboundRuleListResult", "PATAuthTypeConnectionProperties", "PatchResourceTags", "PatchResourceTagsAndSku", + "Pool", "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", @@ -354,18 +415,16 @@ "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", "Project", - "ProjectListResult", + "ProjectCapabilityHost", + "ProjectCapabilityHostProperties", "ProjectProperties", "ProvisioningIssue", "ProvisioningIssueProperties", "ProxyResource", "QuotaLimit", "QuotaTier", - "QuotaTierListResult", "QuotaTierProperties", "QuotaTierUpgradeEligibilityInfo", - "RaiBlockListItemsResult", - "RaiBlockListResult", "RaiBlocklist", "RaiBlocklistConfig", "RaiBlocklistItem", @@ -373,17 +432,23 @@ "RaiBlocklistItemProperties", "RaiBlocklistProperties", "RaiContentFilter", - "RaiContentFilterListResult", "RaiContentFilterProperties", + "RaiExternalSafetyProvider", + "RaiExternalSafetyProviderProperties", + "RaiExternalSafetyProviderSchema", + "RaiExternalSafetyProviderSchemaProperties", "RaiMonitorConfig", "RaiPolicy", "RaiPolicyContentFilter", - "RaiPolicyListResult", "RaiPolicyProperties", + "RaiSafetyProviderConfig", + "RaiToolLabel", + "RaiToolLabelProperties", + "RaiToolLabelPropertiesAccountScope", + "RaiToolLabelPropertiesProjectScopesItem", "RaiTopic", "RaiTopicConfig", "RaiTopicProperties", - "RaiTopicResult", "RegenerateKeyParameters", "RegionSetting", "ReplacementConfig", @@ -391,10 +456,12 @@ "Resource", "ResourceBase", "ResourceSku", - "ResourceSkuListResult", "ResourceSkuRestrictionInfo", "ResourceSkuRestrictions", + "RoleBasedBuiltInAuthorizationPolicy", + "RootError", "SASAuthTypeConnectionProperties", + "SafetyProviderConfig", "ServicePrincipalAuthTypeConnectionProperties", "Sku", "SkuAvailability", @@ -404,19 +471,28 @@ "SkuResource", "SystemData", "ThrottlingRule", + "TrafficRoutingRule", "Usage", "UsageListResult", "UserAssignedIdentity", "UserOwnedAmlWorkspace", "UserOwnedStorage", "UsernamePasswordAuthTypeConnectionProperties", + "VersionedAgentReference", "VirtualNetworkRule", "AbusePenaltyAction", "ActionType", + "AgentDeploymentProvisioningState", + "AgentDeploymentState", + "AgentDeploymentType", + "AgentProtocol", + "AgenticApplicationProvisioningState", + "BuiltInAuthorizationScheme", "ByPassSelection", "CapabilityHostKind", "CapabilityHostProvisioningState", "CommitmentPlanProvisioningState", + "ComputeProvisioningState", "ConnectionAuthType", "ConnectionCategory", "ConnectionGroup", @@ -426,12 +502,21 @@ "DeploymentModelVersionUpgradeOption", "DeploymentProvisioningState", "DeploymentScaleType", + "DeploymentState", "DeprecationStatus", "EncryptionScopeProvisioningState", "EncryptionScopeState", + "FirewallSku", "HostingModel", + "IdentityKind", + "IdentityManagementType", + "IdentityProvisioningState", + "IsolationMode", "KeyName", "KeySource", + "ManagedNetworkKind", + "ManagedNetworkProvisioningState", + "ManagedNetworkStatus", "ManagedPERequirement", "ManagedPEStatus", "ModelLifecycleStatus", @@ -443,6 +528,7 @@ "ProvisioningState", "PublicNetworkAccess", "QuotaUsageStatus", + "RaiActionType", "RaiPolicyContentSource", "RaiPolicyMode", "RaiPolicyType", @@ -450,11 +536,17 @@ "ResourceSkuRestrictionsReasonCode", "ResourceSkuRestrictionsType", "RoutingMethods", + "RuleCategory", + "RuleStatus", + "RuleType", "ScenarioType", + "ServiceTier", "SkuTier", "TierUpgradePolicy", + "TrafficRoutingProtocol", "UnitType", "UpgradeAvailabilityStatus", + "VmPriority", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_enums.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_enums.py new file mode 100644 index 000000000000..7f14a692b57b --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_enums.py @@ -0,0 +1,1137 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AbusePenaltyAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action of AbusePenalty.""" + + THROTTLE = "Throttle" + """THROTTLE.""" + BLOCK = "Block" + """BLOCK.""" + + +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal + only APIs. + """ + + INTERNAL = "Internal" + """Actions are for internal-only APIs.""" + + +class AgentDeploymentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of an agentic deployment, as an Azure resource.""" + + SUCCEEDED = "Succeeded" + """The deployment was successfully completed.""" + FAILED = "Failed" + """The deployment failed.""" + CANCELED = "Canceled" + """The deployment was canceled.""" + CREATING = "Creating" + """The deployment is being created.""" + UPDATING = "Updating" + """The deployment is being updated.""" + DELETING = "Deleting" + """The deployment is being deleted.""" + + +class AgentDeploymentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current operational state of the agentic functionality represented by this deployment.""" + + STARTING = "Starting" + """The deployment is starting.""" + RUNNING = "Running" + """The deployment started/is operational.""" + STOPPING = "Stopping" + """The deployment is being stopped.""" + STOPPED = "Stopped" + """The deployment was stopped.""" + FAILED = "Failed" + """The deployment failed.""" + DELETING = "Deleting" + """The deployment is being deleted.""" + DELETED = "Deleted" + """The deployment was deleted.""" + UPDATING = "Updating" + """The deployment is being updated.""" + + +class AgentDeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the type of deployment for an agent, indicating how the underlying compute and + network infrastructure is managed. + """ + + MANAGED = "Managed" + """The underlying infra is managed by the platform in the deployer's subscription.""" + HOSTED = "Hosted" + """The underlying infra is owned by the platform.""" + CUSTOM = "Custom" + """The underlying infra is provisioned by the deployer (BYO).""" + + +class AgenticApplicationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of an agentic application.""" + + SUCCEEDED = "Succeeded" + """The application was successfully provisioned.""" + FAILED = "Failed" + """The application provisioning failed.""" + CANCELED = "Canceled" + """The application provisioning was canceled.""" + CREATING = "Creating" + """The application is being created.""" + UPDATING = "Updating" + """The application is being updated.""" + DELETING = "Deleting" + """The application is being deleted.""" + + +class AgentProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Protocol used by the agent/exposed by a deployment.""" + + AGENT = "Agent" + """Agent protocol (aka Active).""" + A2_A = "A2A" + """Agent2Agent standard.""" + RESPONSES = "Responses" + """OpenAI-compatible.""" + + +class BuiltInAuthorizationScheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Authorization scheme type.""" + + DEFAULT = "Default" + """Standard AzureML RBAC.""" + ORGANIZATION_SCOPE = "OrganizationScope" + """Claim-based, requires membership in the tenant.""" + CHANNELS = "Channels" + """Channels-specific (AzureBotService) authorization.""" + CUSTOM = "Custom" + """Custom scheme defined by the application author.""" + + +class ByPassSelection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Setting for trusted services.""" + + NONE = "None" + """NONE.""" + AZURE_SERVICES = "AzureServices" + """AZURE_SERVICES.""" + + +class CapabilityHostKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of CapabilityHostKind.""" + + AGENTS = "Agents" + """AGENTS.""" + + +class CapabilityHostProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of capability host.""" + + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + FAILED = "Failed" + """FAILED.""" + CANCELED = "Canceled" + """CANCELED.""" + CREATING = "Creating" + """CREATING.""" + UPDATING = "Updating" + """UPDATING.""" + DELETING = "Deleting" + """DELETING.""" + + +class CommitmentPlanProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the resource at the time the operation was called.""" + + ACCEPTED = "Accepted" + """ACCEPTED.""" + CREATING = "Creating" + """CREATING.""" + DELETING = "Deleting" + """DELETING.""" + MOVING = "Moving" + """MOVING.""" + FAILED = "Failed" + """FAILED.""" + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + CANCELED = "Canceled" + """CANCELED.""" + + +class ComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of a compute resource.""" + + ACCEPTED = "Accepted" + """ACCEPTED.""" + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + FAILED = "Failed" + """FAILED.""" + CANCELED = "Canceled" + """CANCELED.""" + DELETING = "Deleting" + """DELETING.""" + SCALING = "Scaling" + """SCALING.""" + DISABLED = "Disabled" + """DISABLED.""" + + +class ConnectionAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Authentication type of the connection target.""" + + PAT = "PAT" + """PAT.""" + MANAGED_IDENTITY = "ManagedIdentity" + """MANAGED_IDENTITY.""" + USERNAME_PASSWORD = "UsernamePassword" + """USERNAME_PASSWORD.""" + NONE = "None" + """NONE.""" + SAS = "SAS" + """SAS.""" + ACCOUNT_KEY = "AccountKey" + """ACCOUNT_KEY.""" + SERVICE_PRINCIPAL = "ServicePrincipal" + """SERVICE_PRINCIPAL.""" + ACCESS_KEY = "AccessKey" + """ACCESS_KEY.""" + API_KEY = "ApiKey" + """API_KEY.""" + CUSTOM_KEYS = "CustomKeys" + """CUSTOM_KEYS.""" + O_AUTH2 = "OAuth2" + """O_AUTH2.""" + AAD = "AAD" + """AAD.""" + DELEGATED_SAS = "DelegatedSAS" + """DELEGATED_SAS.""" + PROJECT_MANAGED_IDENTITY = "ProjectManagedIdentity" + """PROJECT_MANAGED_IDENTITY.""" + ACCOUNT_MANAGED_IDENTITY = "AccountManagedIdentity" + """ACCOUNT_MANAGED_IDENTITY.""" + USER_ENTRA_TOKEN = "UserEntraToken" + """USER_ENTRA_TOKEN.""" + AGENT_USER_IMPERSONATION = "AgentUserImpersonation" + """AGENT_USER_IMPERSONATION.""" + AGENTIC_IDENTITY_TOKEN = "AgenticIdentityToken" + """AGENTIC_IDENTITY_TOKEN.""" + AGENTIC_USER = "AgenticUser" + """AGENTIC_USER.""" + + +class ConnectionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Category of the connection.""" + + PYTHON_FEED = "PythonFeed" + """PYTHON_FEED.""" + CONTAINER_REGISTRY = "ContainerRegistry" + """CONTAINER_REGISTRY.""" + GIT = "Git" + """GIT.""" + S3 = "S3" + """S3.""" + SNOWFLAKE = "Snowflake" + """SNOWFLAKE.""" + AZURE_KEY_VAULT = "AzureKeyVault" + """AZURE_KEY_VAULT.""" + AZURE_SQL_DB = "AzureSqlDb" + """AZURE_SQL_DB.""" + AZURE_SYNAPSE_ANALYTICS = "AzureSynapseAnalytics" + """AZURE_SYNAPSE_ANALYTICS.""" + AZURE_MY_SQL_DB = "AzureMySqlDb" + """AZURE_MY_SQL_DB.""" + AZURE_POSTGRES_DB = "AzurePostgresDb" + """AZURE_POSTGRES_DB.""" + ADLS_GEN2 = "ADLSGen2" + """ADLS_GEN2.""" + AZURE_CONTAINER_APP_ENVIRONMENT = "AzureContainerAppEnvironment" + """AZURE_CONTAINER_APP_ENVIRONMENT.""" + REDIS = "Redis" + """REDIS.""" + API_KEY = "ApiKey" + """API_KEY.""" + AZURE_OPEN_AI = "AzureOpenAI" + """AZURE_OPEN_AI.""" + AI_SERVICES = "AIServices" + """AI_SERVICES.""" + COGNITIVE_SEARCH = "CognitiveSearch" + """COGNITIVE_SEARCH.""" + COGNITIVE_SERVICE = "CognitiveService" + """COGNITIVE_SERVICE.""" + CUSTOM_KEYS = "CustomKeys" + """CUSTOM_KEYS.""" + AZURE_BLOB = "AzureBlob" + """AZURE_BLOB.""" + AZURE_STORAGE_ACCOUNT = "AzureStorageAccount" + """AZURE_STORAGE_ACCOUNT.""" + AZURE_ONE_LAKE = "AzureOneLake" + """AZURE_ONE_LAKE.""" + COSMOS_DB = "CosmosDb" + """COSMOS_DB.""" + COSMOS_DB_MONGO_DB_API = "CosmosDbMongoDbApi" + """COSMOS_DB_MONGO_DB_API.""" + AZURE_DATA_EXPLORER = "AzureDataExplorer" + """AZURE_DATA_EXPLORER.""" + AZURE_MARIA_DB = "AzureMariaDb" + """AZURE_MARIA_DB.""" + AZURE_DATABRICKS_DELTA_LAKE = "AzureDatabricksDeltaLake" + """AZURE_DATABRICKS_DELTA_LAKE.""" + AZURE_SQL_MI = "AzureSqlMi" + """AZURE_SQL_MI.""" + AZURE_TABLE_STORAGE = "AzureTableStorage" + """AZURE_TABLE_STORAGE.""" + AMAZON_RDS_FOR_ORACLE = "AmazonRdsForOracle" + """AMAZON_RDS_FOR_ORACLE.""" + AMAZON_RDS_FOR_SQL_SERVER = "AmazonRdsForSqlServer" + """AMAZON_RDS_FOR_SQL_SERVER.""" + AMAZON_REDSHIFT = "AmazonRedshift" + """AMAZON_REDSHIFT.""" + DB2 = "Db2" + """DB2.""" + DRILL = "Drill" + """DRILL.""" + GOOGLE_BIG_QUERY = "GoogleBigQuery" + """GOOGLE_BIG_QUERY.""" + GREENPLUM = "Greenplum" + """GREENPLUM.""" + HBASE = "Hbase" + """HBASE.""" + HIVE = "Hive" + """HIVE.""" + IMPALA = "Impala" + """IMPALA.""" + INFORMIX = "Informix" + """INFORMIX.""" + MARIA_DB = "MariaDb" + """MARIA_DB.""" + MICROSOFT_ACCESS = "MicrosoftAccess" + """MICROSOFT_ACCESS.""" + MY_SQL = "MySql" + """MY_SQL.""" + NETEZZA = "Netezza" + """NETEZZA.""" + ORACLE = "Oracle" + """ORACLE.""" + PHOENIX = "Phoenix" + """PHOENIX.""" + POSTGRE_SQL = "PostgreSql" + """POSTGRE_SQL.""" + PRESTO = "Presto" + """PRESTO.""" + SAP_OPEN_HUB = "SapOpenHub" + """SAP_OPEN_HUB.""" + SAP_BW = "SapBw" + """SAP_BW.""" + SAP_HANA = "SapHana" + """SAP_HANA.""" + SAP_TABLE = "SapTable" + """SAP_TABLE.""" + SPARK = "Spark" + """SPARK.""" + SQL_SERVER = "SqlServer" + """SQL_SERVER.""" + SYBASE = "Sybase" + """SYBASE.""" + TERADATA = "Teradata" + """TERADATA.""" + VERTICA = "Vertica" + """VERTICA.""" + PINECONE = "Pinecone" + """PINECONE.""" + DATABRICKS = "Databricks" + """DATABRICKS.""" + CASSANDRA = "Cassandra" + """CASSANDRA.""" + COUCHBASE = "Couchbase" + """COUCHBASE.""" + MONGO_DB_V2 = "MongoDbV2" + """MONGO_DB_V2.""" + MONGO_DB_ATLAS = "MongoDbAtlas" + """MONGO_DB_ATLAS.""" + AMAZON_S3_COMPATIBLE = "AmazonS3Compatible" + """AMAZON_S3_COMPATIBLE.""" + FILE_SERVER = "FileServer" + """FILE_SERVER.""" + FTP_SERVER = "FtpServer" + """FTP_SERVER.""" + GOOGLE_CLOUD_STORAGE = "GoogleCloudStorage" + """GOOGLE_CLOUD_STORAGE.""" + HDFS = "Hdfs" + """HDFS.""" + ORACLE_CLOUD_STORAGE = "OracleCloudStorage" + """ORACLE_CLOUD_STORAGE.""" + SFTP = "Sftp" + """SFTP.""" + GENERIC_HTTP = "GenericHttp" + """GENERIC_HTTP.""" + O_DATA_REST = "ODataRest" + """O_DATA_REST.""" + ODBC = "Odbc" + """ODBC.""" + GENERIC_REST = "GenericRest" + """GENERIC_REST.""" + REMOTE_TOOL = "RemoteTool" + """REMOTE_TOOL.""" + AMAZON_MWS = "AmazonMws" + """AMAZON_MWS.""" + CONCUR = "Concur" + """CONCUR.""" + DYNAMICS = "Dynamics" + """DYNAMICS.""" + DYNAMICS_AX = "DynamicsAx" + """DYNAMICS_AX.""" + DYNAMICS_CRM = "DynamicsCrm" + """DYNAMICS_CRM.""" + GOOGLE_AD_WORDS = "GoogleAdWords" + """GOOGLE_AD_WORDS.""" + HUBSPOT = "Hubspot" + """HUBSPOT.""" + JIRA = "Jira" + """JIRA.""" + MAGENTO = "Magento" + """MAGENTO.""" + MARKETO = "Marketo" + """MARKETO.""" + OFFICE365 = "Office365" + """OFFICE365.""" + ELOQUA = "Eloqua" + """ELOQUA.""" + RESPONSYS = "Responsys" + """RESPONSYS.""" + ORACLE_SERVICE_CLOUD = "OracleServiceCloud" + """ORACLE_SERVICE_CLOUD.""" + PAY_PAL = "PayPal" + """PAY_PAL.""" + QUICK_BOOKS = "QuickBooks" + """QUICK_BOOKS.""" + SALESFORCE = "Salesforce" + """SALESFORCE.""" + SALESFORCE_SERVICE_CLOUD = "SalesforceServiceCloud" + """SALESFORCE_SERVICE_CLOUD.""" + SALESFORCE_MARKETING_CLOUD = "SalesforceMarketingCloud" + """SALESFORCE_MARKETING_CLOUD.""" + SAP_CLOUD_FOR_CUSTOMER = "SapCloudForCustomer" + """SAP_CLOUD_FOR_CUSTOMER.""" + SAP_ECC = "SapEcc" + """SAP_ECC.""" + SERVICE_NOW = "ServiceNow" + """SERVICE_NOW.""" + SHARE_POINT_ONLINE_LIST = "SharePointOnlineList" + """SHARE_POINT_ONLINE_LIST.""" + SHOPIFY = "Shopify" + """SHOPIFY.""" + SQUARE = "Square" + """SQUARE.""" + WEB_TABLE = "WebTable" + """WEB_TABLE.""" + XERO = "Xero" + """XERO.""" + ZOHO = "Zoho" + """ZOHO.""" + GENERIC_CONTAINER_REGISTRY = "GenericContainerRegistry" + """GENERIC_CONTAINER_REGISTRY.""" + ELASTICSEARCH = "Elasticsearch" + """ELASTICSEARCH.""" + APP_INSIGHTS = "AppInsights" + """APP_INSIGHTS.""" + APP_CONFIG = "AppConfig" + """APP_CONFIG.""" + OPEN_AI = "OpenAI" + """OPEN_AI.""" + SERP = "Serp" + """SERP.""" + BING_LLM_SEARCH = "BingLLMSearch" + """BING_LLM_SEARCH.""" + SERVERLESS = "Serverless" + """SERVERLESS.""" + MANAGED_ONLINE_ENDPOINT = "ManagedOnlineEndpoint" + """MANAGED_ONLINE_ENDPOINT.""" + API_MANAGEMENT = "ApiManagement" + """API_MANAGEMENT.""" + MODEL_GATEWAY = "ModelGateway" + """MODEL_GATEWAY.""" + GROUNDING_WITH_BING_SEARCH = "GroundingWithBingSearch" + """GROUNDING_WITH_BING_SEARCH.""" + GROUNDING_WITH_CUSTOM_SEARCH = "GroundingWithCustomSearch" + """GROUNDING_WITH_CUSTOM_SEARCH.""" + SHAREPOINT = "Sharepoint" + """SHAREPOINT.""" + MICROSOFT_FABRIC = "MicrosoftFabric" + """MICROSOFT_FABRIC.""" + POWER_PLATFORM_ENVIRONMENT = "PowerPlatformEnvironment" + """POWER_PLATFORM_ENVIRONMENT.""" + REMOTE_A2_A = "RemoteA2A" + """REMOTE_A2_A.""" + + +class ConnectionGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Group based on connection category.""" + + AZURE = "Azure" + """AZURE.""" + AZURE_AI = "AzureAI" + """AZURE_AI.""" + DATABASE = "Database" + """DATABASE.""" + NO_SQL = "NoSQL" + """NO_SQL.""" + FILE = "File" + """FILE.""" + GENERIC_PROTOCOL = "GenericProtocol" + """GENERIC_PROTOCOL.""" + SERVICES_AND_APPS = "ServicesAndApps" + """SERVICES_AND_APPS.""" + + +class ContentLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Level at which content is filtered.""" + + LOW = "Low" + """LOW.""" + MEDIUM = "Medium" + """MEDIUM.""" + HIGH = "High" + """HIGH.""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of entity that created the resource.""" + + USER = "User" + """The entity was created by a user.""" + APPLICATION = "Application" + """The entity was created by an application.""" + MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" + KEY = "Key" + """The entity was created by a key.""" + + +class DefenderForAISettingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defender for AI state on the AI resource.""" + + DISABLED = "Disabled" + """DISABLED.""" + ENABLED = "Enabled" + """ENABLED.""" + + +class DeploymentModelVersionUpgradeOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Deployment model version upgrade option.""" + + ONCE_NEW_DEFAULT_VERSION_AVAILABLE = "OnceNewDefaultVersionAvailable" + """ONCE_NEW_DEFAULT_VERSION_AVAILABLE.""" + ONCE_CURRENT_VERSION_EXPIRED = "OnceCurrentVersionExpired" + """ONCE_CURRENT_VERSION_EXPIRED.""" + NO_AUTO_UPGRADE = "NoAutoUpgrade" + """NO_AUTO_UPGRADE.""" + + +class DeploymentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the resource at the time the operation was called.""" + + ACCEPTED = "Accepted" + """ACCEPTED.""" + CREATING = "Creating" + """CREATING.""" + DELETING = "Deleting" + """DELETING.""" + MOVING = "Moving" + """MOVING.""" + FAILED = "Failed" + """FAILED.""" + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + DISABLED = "Disabled" + """DISABLED.""" + CANCELED = "Canceled" + """CANCELED.""" + + +class DeploymentScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Deployment scale type.""" + + STANDARD = "Standard" + """STANDARD.""" + MANUAL = "Manual" + """MANUAL.""" + + +class DeploymentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the deployment. Controls whether the deployment is accepting inference requests. + Use 'Running' for active deployments that process requests, or 'Paused' to temporarily stop + inference while preserving the deployment configuration. + """ + + RUNNING = "Running" + """The deployment is running and accepting inference requests.""" + PAUSED = "Paused" + """The deployment is paused and not accepting inference requests.""" + + +class DeprecationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether the deprecation date is a confirmed planned end-of-life date or an estimated + deprecation date. When 'Planned', the deprecation date represents a confirmed and communicated + model end-of-life date. When 'Tentative', the deprecation date is an estimated timeline that + may be subject to change. + """ + + PLANNED = "Planned" + """PLANNED.""" + TENTATIVE = "Tentative" + """TENTATIVE.""" + + +class EncryptionScopeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the resource at the time the operation was called.""" + + ACCEPTED = "Accepted" + """ACCEPTED.""" + CREATING = "Creating" + """CREATING.""" + DELETING = "Deleting" + """DELETING.""" + MOVING = "Moving" + """MOVING.""" + FAILED = "Failed" + """FAILED.""" + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + CANCELED = "Canceled" + """CANCELED.""" + + +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryptionScope state.""" + + DISABLED = "Disabled" + """DISABLED.""" + ENABLED = "Enabled" + """ENABLED.""" + + +class FirewallSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Firewall Sku used for FQDN Rules.""" + + STANDARD = "Standard" + """STANDARD.""" + BASIC = "Basic" + """BASIC.""" + + +class HostingModel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Account hosting model.""" + + WEB = "Web" + """WEB.""" + CONNECTED_CONTAINER = "ConnectedContainer" + """CONNECTED_CONTAINER.""" + DISCONNECTED_CONTAINER = "DisconnectedContainer" + """DISCONNECTED_CONTAINER.""" + PROVISIONED_WEB = "ProvisionedWeb" + """PROVISIONED_WEB.""" + + +class IdentityKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the kind of Entra identity described by this object.""" + + AGENT_BLUEPRINT = "AgentBlueprint" + """Represents a class identity, used for agentic applications.""" + AGENT_INSTANCE = "AgentInstance" + """Represents an instance identity.""" + AGENTIC_USER = "AgenticUser" + """Represents an agentic instance identity with user-like traits.""" + MANAGED = "Managed" + """Represents a classic managed identity.""" + NONE = "None" + """No identity.""" + + +class IdentityManagementType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enumeration of identity types, from the perspective of management.""" + + SYSTEM = "System" + """Platform-managed identity.""" + USER = "User" + """User-managed identity.""" + NONE = "None" + """No identity.""" + + +class IdentityProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the provisioning state of an identity resource.""" + + CREATING = "Creating" + """Identity is being created.""" + UPDATING = "Updating" + """Identity is being updated.""" + SUCCEEDED = "Succeeded" + """Identity has been successfully provisioned.""" + FAILED = "Failed" + """Identity provisioning has failed.""" + CANCELED = "Canceled" + """Identity provisioning has been canceled.""" + DELETING = "Deleting" + """Identity is being deleted.""" + + +class IsolationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Isolation mode for the managed network of a cognitive services account.""" + + DISABLED = "Disabled" + """DISABLED.""" + ALLOW_INTERNET_OUTBOUND = "AllowInternetOutbound" + """ALLOW_INTERNET_OUTBOUND.""" + ALLOW_ONLY_APPROVED_OUTBOUND = "AllowOnlyApprovedOutbound" + """ALLOW_ONLY_APPROVED_OUTBOUND.""" + + +class KeyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """key name to generate (Key1|Key2).""" + + KEY1 = "Key1" + """KEY1.""" + KEY2 = "Key2" + """KEY2.""" + + +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enumerates the possible value of keySource for Encryption.""" + + MICROSOFT_COGNITIVE_SERVICES = "Microsoft.CognitiveServices" + """MICROSOFT_COGNITIVE_SERVICES.""" + MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + """MICROSOFT_KEY_VAULT.""" + + +class ManagedNetworkKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Kind of the managed network. Users can switch from V1 to V2 for granular access controls, + but cannot switch back to V1 once V2 is enabled. + """ + + V1 = "V1" + """V1.""" + V2 = "V2" + """V2.""" + + +class ManagedNetworkProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ManagedNetworkProvisioningState.""" + + DEFERRED = "Deferred" + """DEFERRED.""" + UPDATING = "Updating" + """UPDATING.""" + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + FAILED = "Failed" + """FAILED.""" + DELETING = "Deleting" + """DELETING.""" + DELETED = "Deleted" + """DELETED.""" + + +class ManagedNetworkStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status for the managed network of a cognitive services account.""" + + INACTIVE = "Inactive" + """INACTIVE.""" + ACTIVE = "Active" + """ACTIVE.""" + + +class ManagedPERequirement(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ManagedPERequirement.""" + + REQUIRED = "Required" + """REQUIRED.""" + NOT_REQUIRED = "NotRequired" + """NOT_REQUIRED.""" + NOT_APPLICABLE = "NotApplicable" + """NOT_APPLICABLE.""" + + +class ManagedPEStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ManagedPEStatus.""" + + INACTIVE = "Inactive" + """INACTIVE.""" + ACTIVE = "Active" + """ACTIVE.""" + NOT_APPLICABLE = "NotApplicable" + """NOT_APPLICABLE.""" + + +class ModelLifecycleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Model lifecycle status.""" + + STABLE = "Stable" + """Legacy state. Replaced with GenerallyAvailable going forward.""" + PREVIEW = "Preview" + """Model is in preview and may be subject to changes.""" + GENERALLY_AVAILABLE = "GenerallyAvailable" + """Model is generally available for production use.""" + DEPRECATING = "Deprecating" + """Model is being deprecated and will be removed in the future. Only customers with existing + deployments can create new deployments with this model.""" + DEPRECATED = "Deprecated" + """Model has been deprecated, also known as retired, and is no longer supported. Inference calls + to deployments of models in this lifecycle state will return 410 errors.""" + LEGACY = "Legacy" + """Model is a legacy version that is no longer recommended for use. Customers should migrate to + newer models. Check replacementConfig for upgrade information.""" + + +class NetworkRuleAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default action when no rule from ipRules and from virtualNetworkRules match. This is only + used after the bypass property has been evaluated. + """ + + ALLOW = "Allow" + """ALLOW.""" + DENY = "Deny" + """DENY.""" + + +class NspAccessRuleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Direction of Access Rule.""" + + INBOUND = "Inbound" + """INBOUND.""" + OUTBOUND = "Outbound" + """OUTBOUND.""" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + """Indicates the operation is initiated by a user.""" + SYSTEM = "system" + """Indicates the operation is initiated by a system.""" + USER_SYSTEM = "user,system" + """Indicates the operation is initiated by a user or system.""" + + +class PrivateEndpointConnectionProvisioningState( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): + """The current provisioning state.""" + + SUCCEEDED = "Succeeded" + """Connection has been provisioned.""" + CREATING = "Creating" + """Connection is being created.""" + DELETING = "Deleting" + """Connection is being deleted.""" + FAILED = "Failed" + """Connection provisioning has failed.""" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + """Connection waiting for approval or rejection.""" + APPROVED = "Approved" + """Connection approved.""" + REJECTED = "Rejected" + """Connection Rejected.""" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the cognitive services account at the time the operation was called.""" + + ACCEPTED = "Accepted" + """ACCEPTED.""" + CREATING = "Creating" + """CREATING.""" + DELETING = "Deleting" + """DELETING.""" + MOVING = "Moving" + """MOVING.""" + FAILED = "Failed" + """FAILED.""" + SUCCEEDED = "Succeeded" + """SUCCEEDED.""" + CANCELED = "Canceled" + """CANCELED.""" + RESOLVING_DNS = "ResolvingDNS" + """RESOLVING_DNS.""" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not public endpoint access is allowed for this account.""" + + ENABLED = "Enabled" + """ENABLED.""" + DISABLED = "Disabled" + """DISABLED.""" + + +class QuotaUsageStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cognitive Services account quota usage status.""" + + INCLUDED = "Included" + """INCLUDED.""" + BLOCKED = "Blocked" + """BLOCKED.""" + IN_OVERAGE = "InOverage" + """IN_OVERAGE.""" + UNKNOWN = "Unknown" + """UNKNOWN.""" + + +class RaiActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action types to apply to the content filters.""" + + NONE = "None" + """NONE.""" + BLOCKING = "BLOCKING" + """BLOCKING.""" + ANNOTATING = "ANNOTATING" + """ANNOTATING.""" + HITL = "HITL" + """HITL.""" + RETRY = "RETRY" + """RETRY.""" + + +class RaiPolicyContentSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Content source to apply the Content Filters.""" + + PROMPT = "Prompt" + """PROMPT.""" + COMPLETION = "Completion" + """COMPLETION.""" + PRE_TOOL_CALL = "PreToolCall" + """PRE_TOOL_CALL.""" + POST_TOOL_CALL = "PostToolCall" + """POST_TOOL_CALL.""" + PRE_RUN = "PreRun" + """PRE_RUN.""" + POST_RUN = "PostRun" + """POST_RUN.""" + + +class RaiPolicyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, + Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2025-06-01. It is the same as + 'Deferred' in previous version. + """ + + DEFAULT = "Default" + """DEFAULT.""" + DEFERRED = "Deferred" + """DEFERRED.""" + BLOCKING = "Blocking" + """BLOCKING.""" + ASYNCHRONOUS_FILTER = "Asynchronous_filter" + """ASYNCHRONOUS_FILTER.""" + + +class RaiPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Content Filters policy type.""" + + USER_MANAGED = "UserManaged" + """USER_MANAGED.""" + SYSTEM_MANAGED = "SystemManaged" + """SYSTEM_MANAGED.""" + + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + NONE = "None" + """NONE.""" + SYSTEM_ASSIGNED = "SystemAssigned" + """SYSTEM_ASSIGNED.""" + USER_ASSIGNED = "UserAssigned" + """USER_ASSIGNED.""" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + """SYSTEM_ASSIGNED_USER_ASSIGNED.""" + + +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for restriction.""" + + QUOTA_ID = "QuotaId" + """QUOTA_ID.""" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + """NOT_AVAILABLE_FOR_SUBSCRIPTION.""" + + +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of restrictions.""" + + LOCATION = "Location" + """LOCATION.""" + ZONE = "Zone" + """ZONE.""" + + +class RoutingMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Multiregion routing methods.""" + + PRIORITY = "Priority" + """PRIORITY.""" + WEIGHTED = "Weighted" + """WEIGHTED.""" + PERFORMANCE = "Performance" + """PERFORMANCE.""" + + +class RuleCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Category of a managed network Outbound Rule of a cognitive services account.""" + + REQUIRED = "Required" + """REQUIRED.""" + RECOMMENDED = "Recommended" + """RECOMMENDED.""" + USER_DEFINED = "UserDefined" + """USER_DEFINED.""" + DEPENDENCY = "Dependency" + """DEPENDENCY.""" + + +class RuleStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of a managed network Outbound Rule of a cognitive services account.""" + + INACTIVE = "Inactive" + """INACTIVE.""" + ACTIVE = "Active" + """ACTIVE.""" + PROVISIONING = "Provisioning" + """PROVISIONING.""" + DELETING = "Deleting" + """DELETING.""" + FAILED = "Failed" + """FAILED.""" + + +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of a managed network Outbound Rule of a cognitive services account.""" + + FQDN = "FQDN" + """FQDN.""" + PRIVATE_ENDPOINT = "PrivateEndpoint" + """PRIVATE_ENDPOINT.""" + SERVICE_TAG = "ServiceTag" + """SERVICE_TAG.""" + + +class ScenarioType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies what features in AI Foundry network injection applies to. Currently only supports + 'agent' for agent scenarios. 'none' means no network injection. + """ + + NONE = "none" + """NONE.""" + AGENT = "agent" + """AGENT.""" + + +class ServiceTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The service tier for the deployment. Determines the pricing and performance level for request + processing. Use 'Default' for standard pricing or 'Priority' for higher-priority processing + with premium pricing. Note: Pause operations are only supported on Standard, DataZoneStandard, + and GlobalStandard SKUs. + """ + + DEFAULT = "Default" + """Default service tier meaning the request will be processed with the standard pricing and + performance for the selected model.""" + PRIORITY = "Priority" + """Priority service tier meaning the request will be processed with higher pricing and performance + for the selected model.""" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This field is required to be implemented by the Resource Provider if the service has more than + one tier, but is not required on a PUT. + """ + + FREE = "Free" + """FREE.""" + BASIC = "Basic" + """BASIC.""" + STANDARD = "Standard" + """STANDARD.""" + PREMIUM = "Premium" + """PREMIUM.""" + ENTERPRISE = "Enterprise" + """ENTERPRISE.""" + + +class TierUpgradePolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the tier upgrade policy for the subscription.""" + + ONCE_UPGRADE_IS_AVAILABLE = "OnceUpgradeIsAvailable" + """ONCE_UPGRADE_IS_AVAILABLE.""" + NO_AUTO_UPGRADE = "NoAutoUpgrade" + """NO_AUTO_UPGRADE.""" + + +class TrafficRoutingProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Traffic routing protocol, used to distribute an application's inbound traffic to its + deployments. + """ + + FIXED_RATIO = "FixedRatio" + """Percentage based routing.""" + + +class UnitType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of the metric.""" + + COUNT = "Count" + """COUNT.""" + BYTES = "Bytes" + """BYTES.""" + SECONDS = "Seconds" + """SECONDS.""" + PERCENT = "Percent" + """PERCENT.""" + COUNT_PER_SECOND = "CountPerSecond" + """COUNT_PER_SECOND.""" + BYTES_PER_SECOND = "BytesPerSecond" + """BYTES_PER_SECOND.""" + MILLISECONDS = "Milliseconds" + """MILLISECONDS.""" + + +class UpgradeAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether an upgrade to the next quota tier is available.""" + + AVAILABLE = "Available" + """AVAILABLE.""" + NOT_AVAILABLE = "NotAvailable" + """NOT_AVAILABLE.""" + + +class VmPriority(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VM priority for a compute pool.""" + + REGULAR = "Regular" + """REGULAR.""" + SPOT = "Spot" + """SPOT.""" diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py new file mode 100644 index 000000000000..9f20d876e64f --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/models/_models.py @@ -0,0 +1,9739 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import AgentDeploymentType, BuiltInAuthorizationScheme, ConnectionAuthType, RuleType + +if TYPE_CHECKING: + from .. import models as _models + + +class ConnectionPropertiesV2(_Model): + """Connection property base schema. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AADAuthTypeConnectionProperties, AccessKeyAuthTypeConnectionProperties, + AccountKeyAuthTypeConnectionProperties, ApiKeyAuthConnectionProperties, + CustomKeysConnectionProperties, ManagedIdentityAuthTypeConnectionProperties, + NoneAuthTypeConnectionProperties, OAuth2AuthTypeConnectionProperties, + PATAuthTypeConnectionProperties, SASAuthTypeConnectionProperties, + ServicePrincipalAuthTypeConnectionProperties, UsernamePasswordAuthTypeConnectionProperties + + :ivar auth_type: Authentication type of the connection target. Required. Known values are: + "PAT", "ManagedIdentity", "UsernamePassword", "None", "SAS", "AccountKey", "ServicePrincipal", + "AccessKey", "ApiKey", "CustomKeys", "OAuth2", "AAD", "DelegatedSAS", "ProjectManagedIdentity", + "AccountManagedIdentity", "UserEntraToken", "AgentUserImpersonation", "AgenticIdentityToken", + and "AgenticUser". + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.ConnectionAuthType + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + """ + + __mapping__: dict[str, _Model] = {} + auth_type: str = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) + """Authentication type of the connection target. Required. Known values are: \"PAT\", + \"ManagedIdentity\", \"UsernamePassword\", \"None\", \"SAS\", \"AccountKey\", + \"ServicePrincipal\", \"AccessKey\", \"ApiKey\", \"CustomKeys\", \"OAuth2\", \"AAD\", + \"DelegatedSAS\", \"ProjectManagedIdentity\", \"AccountManagedIdentity\", \"UserEntraToken\", + \"AgentUserImpersonation\", \"AgenticIdentityToken\", and \"AgenticUser\".""" + category: Optional[Union[str, "_models.ConnectionCategory"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Category of the connection. Known values are: \"PythonFeed\", \"ContainerRegistry\", \"Git\", + \"S3\", \"Snowflake\", \"AzureKeyVault\", \"AzureSqlDb\", \"AzureSynapseAnalytics\", + \"AzureMySqlDb\", \"AzurePostgresDb\", \"ADLSGen2\", \"AzureContainerAppEnvironment\", + \"Redis\", \"ApiKey\", \"AzureOpenAI\", \"AIServices\", \"CognitiveSearch\", + \"CognitiveService\", \"CustomKeys\", \"AzureBlob\", \"AzureStorageAccount\", \"AzureOneLake\", + \"CosmosDb\", \"CosmosDbMongoDbApi\", \"AzureDataExplorer\", \"AzureMariaDb\", + \"AzureDatabricksDeltaLake\", \"AzureSqlMi\", \"AzureTableStorage\", \"AmazonRdsForOracle\", + \"AmazonRdsForSqlServer\", \"AmazonRedshift\", \"Db2\", \"Drill\", \"GoogleBigQuery\", + \"Greenplum\", \"Hbase\", \"Hive\", \"Impala\", \"Informix\", \"MariaDb\", \"MicrosoftAccess\", + \"MySql\", \"Netezza\", \"Oracle\", \"Phoenix\", \"PostgreSql\", \"Presto\", \"SapOpenHub\", + \"SapBw\", \"SapHana\", \"SapTable\", \"Spark\", \"SqlServer\", \"Sybase\", \"Teradata\", + \"Vertica\", \"Pinecone\", \"Databricks\", \"Cassandra\", \"Couchbase\", \"MongoDbV2\", + \"MongoDbAtlas\", \"AmazonS3Compatible\", \"FileServer\", \"FtpServer\", + \"GoogleCloudStorage\", \"Hdfs\", \"OracleCloudStorage\", \"Sftp\", \"GenericHttp\", + \"ODataRest\", \"Odbc\", \"GenericRest\", \"RemoteTool\", \"AmazonMws\", \"Concur\", + \"Dynamics\", \"DynamicsAx\", \"DynamicsCrm\", \"GoogleAdWords\", \"Hubspot\", \"Jira\", + \"Magento\", \"Marketo\", \"Office365\", \"Eloqua\", \"Responsys\", \"OracleServiceCloud\", + \"PayPal\", \"QuickBooks\", \"Salesforce\", \"SalesforceServiceCloud\", + \"SalesforceMarketingCloud\", \"SapCloudForCustomer\", \"SapEcc\", \"ServiceNow\", + \"SharePointOnlineList\", \"Shopify\", \"Square\", \"WebTable\", \"Xero\", \"Zoho\", + \"GenericContainerRegistry\", \"Elasticsearch\", \"AppInsights\", \"AppConfig\", \"OpenAI\", + \"Serp\", \"BingLLMSearch\", \"Serverless\", \"ManagedOnlineEndpoint\", \"ApiManagement\", + \"ModelGateway\", \"GroundingWithBingSearch\", \"GroundingWithCustomSearch\", \"Sharepoint\", + \"MicrosoftFabric\", \"PowerPlatformEnvironment\", and \"RemoteA2A\".""" + created_by_workspace_arm_id: Optional[str] = rest_field(name="createdByWorkspaceArmId", visibility=["read"]) + error: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Provides the error message if the connection fails.""" + expiry_time: Optional[datetime.datetime] = rest_field( + name="expiryTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + group: Optional[Union[str, "_models.ConnectionGroup"]] = rest_field(visibility=["read"]) + """Group based on connection category. Known values are: \"Azure\", \"AzureAI\", \"Database\", + \"NoSQL\", \"File\", \"GenericProtocol\", and \"ServicesAndApps\".""" + is_shared_to_all: Optional[bool] = rest_field( + name="isSharedToAll", visibility=["read", "create", "update", "delete", "query"] + ) + metadata: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Store user metadata for this connection.""" + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = rest_field( + name="peRequirement", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies how private endpoints are used with this connection: 'Required', 'NotRequired', or + 'NotApplicable'. Known values are: \"Required\", \"NotRequired\", and \"NotApplicable\".""" + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = rest_field( + name="peStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the status of private endpoints for this connection: 'Inactive', 'Active', or + 'NotApplicable'. Known values are: \"Inactive\", \"Active\", and \"NotApplicable\".""" + shared_user_list: Optional[list[str]] = rest_field( + name="sharedUserList", visibility=["read", "create", "update", "delete", "query"] + ) + target: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The connection URL to be used.""" + use_workspace_managed_identity: Optional[bool] = rest_field( + name="useWorkspaceManagedIdentity", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + auth_type: str, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AADAuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="AAD"): + """This connection type covers the AAD auth for any applicable Azure service. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar auth_type: Authentication type of the connection target. Required. AAD. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.AAD + """ + + auth_type: Literal[ConnectionAuthType.AAD] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. AAD.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.AAD # type: ignore + + +class AbusePenalty(_Model): + """The abuse penalty. + + :ivar action: The action of AbusePenalty. Known values are: "Throttle" and "Block". + :vartype action: str or ~azure.mgmt.cognitiveservices.models.AbusePenaltyAction + :ivar rate_limit_percentage: The percentage of rate limit. + :vartype rate_limit_percentage: float + :ivar expiration: The datetime of expiration of the AbusePenalty. + :vartype expiration: ~datetime.datetime + """ + + action: Optional[Union[str, "_models.AbusePenaltyAction"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The action of AbusePenalty. Known values are: \"Throttle\" and \"Block\".""" + rate_limit_percentage: Optional[float] = rest_field( + name="rateLimitPercentage", visibility=["read", "create", "update", "delete", "query"] + ) + """The percentage of rate limit.""" + expiration: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The datetime of expiration of the AbusePenalty.""" + + @overload + def __init__( + self, + *, + action: Optional[Union[str, "_models.AbusePenaltyAction"]] = None, + rate_limit_percentage: Optional[float] = None, + expiration: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccessKeyAuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="AccessKey"): + """AccessKeyAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionAccessKey + :ivar auth_type: Authentication type of the connection target. Required. ACCESS_KEY. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.ACCESS_KEY + """ + + credentials: Optional["_models.ConnectionAccessKey"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auth_type: Literal[ConnectionAuthType.ACCESS_KEY] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. ACCESS_KEY.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionAccessKey"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.ACCESS_KEY # type: ignore + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class Account(Resource): + """Cognitive Services account is an Azure resource representing the provisioned account, it's + type, location and SKU. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services account. + :vartype properties: ~azure.mgmt.cognitiveservices.models.AccountProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cognitiveservices.models.Identity + """ + + properties: Optional["_models.AccountProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services account.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource model definition representing SKU.""" + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identity for the resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.AccountProperties"] = None, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + kind: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.Identity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccountKeyAuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="AccountKey"): + """This connection type covers the account key connection for Azure storage. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: Account key object for connection credential. + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionAccountKey + :ivar auth_type: Authentication type of the connection target. Required. ACCOUNT_KEY. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.ACCOUNT_KEY + """ + + credentials: Optional["_models.ConnectionAccountKey"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Account key object for connection credential.""" + auth_type: Literal[ConnectionAuthType.ACCOUNT_KEY] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. ACCOUNT_KEY.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionAccountKey"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.ACCOUNT_KEY # type: ignore + + +class DeploymentModel(_Model): + """Properties of Cognitive Services account deployment model. + + :ivar publisher: Deployment model publisher. + :vartype publisher: str + :ivar format: Deployment model format. + :vartype format: str + :ivar name: Deployment model name. + :vartype name: str + :ivar version: 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. + :vartype version: str + :ivar source: Optional. Deployment model source ARM resource ID. + :vartype source: str + :ivar source_account: Optional. Source of the model, another Microsoft.CognitiveServices + accounts ARM resource ID. + :vartype source_account: str + :ivar call_rate_limit: The call rate limit Cognitive Services account. + :vartype call_rate_limit: ~azure.mgmt.cognitiveservices.models.CallRateLimit + """ + + publisher: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Deployment model publisher.""" + format: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Deployment model format.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Deployment model name.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + source: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional. Deployment model source ARM resource ID.""" + source_account: Optional[str] = rest_field( + name="sourceAccount", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional. Source of the model, another Microsoft.CognitiveServices accounts ARM resource ID.""" + call_rate_limit: Optional["_models.CallRateLimit"] = rest_field(name="callRateLimit", visibility=["read"]) + """The call rate limit Cognitive Services account.""" + + @overload + def __init__( + self, + *, + publisher: Optional[str] = None, + format: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + source: Optional[str] = None, + source_account: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccountModel(DeploymentModel): + """Cognitive Services account Model. + + :ivar publisher: Deployment model publisher. + :vartype publisher: str + :ivar format: Deployment model format. + :vartype format: str + :ivar name: Deployment model name. + :vartype name: str + :ivar version: 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. + :vartype version: str + :ivar source: Optional. Deployment model source ARM resource ID. + :vartype source: str + :ivar source_account: Optional. Source of the model, another Microsoft.CognitiveServices + accounts ARM resource ID. + :vartype source_account: str + :ivar call_rate_limit: The call rate limit Cognitive Services account. + :vartype call_rate_limit: ~azure.mgmt.cognitiveservices.models.CallRateLimit + :ivar base_model: Properties of Cognitive Services account deployment model. + :vartype base_model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar is_default_version: If the model is default version. + :vartype is_default_version: bool + :ivar skus: The list of Model Sku. + :vartype skus: list[~azure.mgmt.cognitiveservices.models.ModelSku] + :ivar max_capacity: The max capacity. + :vartype max_capacity: int + :ivar capabilities: The capabilities. + :vartype capabilities: dict[str, str] + :ivar finetune_capabilities: The capabilities for finetune models. + :vartype finetune_capabilities: dict[str, str] + :ivar deprecation: Cognitive Services account ModelDeprecationInfo. + :vartype deprecation: ~azure.mgmt.cognitiveservices.models.ModelDeprecationInfo + :ivar replacement_config: Configuration for model replacement. + :vartype replacement_config: ~azure.mgmt.cognitiveservices.models.ReplacementConfig + :ivar model_catalog_asset_id: Asset identifier for the model in the model catalog. + :vartype model_catalog_asset_id: str + :ivar lifecycle_status: Model lifecycle status. Known values are: "Stable", "Preview", + "GenerallyAvailable", "Deprecating", "Deprecated", and "Legacy". + :vartype lifecycle_status: str or ~azure.mgmt.cognitiveservices.models.ModelLifecycleStatus + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + """ + + base_model: Optional["_models.DeploymentModel"] = rest_field( + name="baseModel", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services account deployment model.""" + is_default_version: Optional[bool] = rest_field( + name="isDefaultVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """If the model is default version.""" + skus: Optional[list["_models.ModelSku"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The list of Model Sku.""" + max_capacity: Optional[int] = rest_field( + name="maxCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The max capacity.""" + capabilities: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The capabilities.""" + finetune_capabilities: Optional[dict[str, str]] = rest_field( + name="finetuneCapabilities", visibility=["read", "create", "update", "delete", "query"] + ) + """The capabilities for finetune models.""" + deprecation: Optional["_models.ModelDeprecationInfo"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Cognitive Services account ModelDeprecationInfo.""" + replacement_config: Optional["_models.ReplacementConfig"] = rest_field( + name="replacementConfig", visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for model replacement.""" + model_catalog_asset_id: Optional[str] = rest_field( + name="modelCatalogAssetId", visibility=["read", "create", "update", "delete", "query"] + ) + """Asset identifier for the model in the model catalog.""" + lifecycle_status: Optional[Union[str, "_models.ModelLifecycleStatus"]] = rest_field( + name="lifecycleStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Model lifecycle status. Known values are: \"Stable\", \"Preview\", \"GenerallyAvailable\", + \"Deprecating\", \"Deprecated\", and \"Legacy\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Metadata pertaining to creation and last modification of the resource.""" + + @overload + def __init__( + self, + *, + publisher: Optional[str] = None, + format: Optional[str] = None, + name: Optional[str] = None, + version: Optional[str] = None, + source: Optional[str] = None, + source_account: Optional[str] = None, + base_model: Optional["_models.DeploymentModel"] = None, + is_default_version: Optional[bool] = None, + skus: Optional[list["_models.ModelSku"]] = None, + max_capacity: Optional[int] = None, + capabilities: Optional[dict[str, str]] = None, + finetune_capabilities: Optional[dict[str, str]] = None, + deprecation: Optional["_models.ModelDeprecationInfo"] = None, + replacement_config: Optional["_models.ReplacementConfig"] = None, + model_catalog_asset_id: Optional[str] = None, + lifecycle_status: Optional[Union[str, "_models.ModelLifecycleStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccountProperties(_Model): + """Properties of Cognitive Services account. + + :ivar provisioning_state: Gets the status of the cognitive services account at the time the + operation was called. Known values are: "Accepted", "Creating", "Deleting", "Moving", "Failed", + "Succeeded", "Canceled", and "ResolvingDNS". + :vartype provisioning_state: str or ~azure.mgmt.cognitiveservices.models.ProvisioningState + :ivar endpoint: Endpoint of the created account. + :vartype endpoint: str + :ivar internal_id: The internal identifier (deprecated, do not use this property). + :vartype internal_id: str + :ivar capabilities: Gets the capabilities of the cognitive services account. Each item + indicates the capability of a specific feature. The values are read-only and for reference + only. + :vartype capabilities: list[~azure.mgmt.cognitiveservices.models.SkuCapability] + :ivar is_migrated: If the resource is migrated from an existing key. + :vartype is_migrated: bool + :ivar migration_token: Resource migration token. + :vartype migration_token: str + :ivar sku_change_info: Sku change info of account. + :vartype sku_change_info: ~azure.mgmt.cognitiveservices.models.SkuChangeInfo + :ivar custom_sub_domain_name: Optional subdomain name used for token-based authentication. + :vartype custom_sub_domain_name: str + :ivar network_acls: A collection of rules governing the accessibility from specific network + locations. + :vartype network_acls: ~azure.mgmt.cognitiveservices.models.NetworkRuleSet + :ivar encryption: The encryption properties for this resource. + :vartype encryption: ~azure.mgmt.cognitiveservices.models.Encryption + :ivar user_owned_storage: The storage accounts for this resource. + :vartype user_owned_storage: list[~azure.mgmt.cognitiveservices.models.UserOwnedStorage] + :ivar aml_workspace: The user owned AML account properties. + :vartype aml_workspace: ~azure.mgmt.cognitiveservices.models.UserOwnedAmlWorkspace + :ivar private_endpoint_connections: The private endpoint connection associated with the + Cognitive Services account. + :vartype private_endpoint_connections: + list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :ivar public_network_access: Whether or not public endpoint access is allowed for this account. + Known values are: "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.cognitiveservices.models.PublicNetworkAccess + :ivar api_properties: The api properties for special APIs. + :vartype api_properties: ~azure.mgmt.cognitiveservices.models.ApiProperties + :ivar date_created: Gets the date of cognitive services account creation. + :vartype date_created: str + :ivar call_rate_limit: The call rate limit Cognitive Services account. + :vartype call_rate_limit: ~azure.mgmt.cognitiveservices.models.CallRateLimit + :ivar dynamic_throttling_enabled: The flag to enable dynamic throttling. + :vartype dynamic_throttling_enabled: bool + :ivar stored_completions_disabled: The flag to disable stored completions. + :vartype stored_completions_disabled: bool + :ivar quota_limit: + :vartype quota_limit: ~azure.mgmt.cognitiveservices.models.QuotaLimit + :ivar restrict_outbound_network_access: + :vartype restrict_outbound_network_access: bool + :ivar allowed_fqdn_list: + :vartype allowed_fqdn_list: list[str] + :ivar disable_local_auth: + :vartype disable_local_auth: bool + :ivar endpoints: Dictionary of . + :vartype endpoints: dict[str, str] + :ivar restore: + :vartype restore: bool + :ivar deletion_date: The deletion date, only available for deleted account. + :vartype deletion_date: str + :ivar scheduled_purge_date: The scheduled purge date, only available for deleted account. + :vartype scheduled_purge_date: str + :ivar locations: The multiregion settings of Cognitive Services account. + :vartype locations: ~azure.mgmt.cognitiveservices.models.MultiRegionSettings + :ivar commitment_plan_associations: The commitment plan associations of Cognitive Services + account. + :vartype commitment_plan_associations: + list[~azure.mgmt.cognitiveservices.models.CommitmentPlanAssociation] + :ivar abuse_penalty: The abuse penalty. + :vartype abuse_penalty: ~azure.mgmt.cognitiveservices.models.AbusePenalty + :ivar rai_monitor_config: Cognitive Services Rai Monitor Config. + :vartype rai_monitor_config: ~azure.mgmt.cognitiveservices.models.RaiMonitorConfig + :ivar network_injections: + :vartype network_injections: list[~azure.mgmt.cognitiveservices.models.NetworkInjection] + :ivar allow_project_management: Specifies whether this resource support project management as + child resources, used as containers for access management, data isolation and cost in AI + Foundry. + :vartype allow_project_management: bool + :ivar default_project: Specifies the project, by project name, that is targeted when data plane + endpoints are called without a project parameter. + :vartype default_project: str + :ivar associated_projects: Specifies the projects, by project name, that are associated with + this resource. + :vartype associated_projects: list[str] + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Gets the status of the cognitive services account at the time the operation was called. Known + values are: \"Accepted\", \"Creating\", \"Deleting\", \"Moving\", \"Failed\", \"Succeeded\", + \"Canceled\", and \"ResolvingDNS\".""" + endpoint: Optional[str] = rest_field(visibility=["read"]) + """Endpoint of the created account.""" + internal_id: Optional[str] = rest_field(name="internalId", visibility=["read"]) + """The internal identifier (deprecated, do not use this property).""" + capabilities: Optional[list["_models.SkuCapability"]] = rest_field(visibility=["read"]) + """Gets the capabilities of the cognitive services account. Each item indicates the capability of + a specific feature. The values are read-only and for reference only.""" + is_migrated: Optional[bool] = rest_field(name="isMigrated", visibility=["read"]) + """If the resource is migrated from an existing key.""" + migration_token: Optional[str] = rest_field( + name="migrationToken", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource migration token.""" + sku_change_info: Optional["_models.SkuChangeInfo"] = rest_field(name="skuChangeInfo", visibility=["read"]) + """Sku change info of account.""" + custom_sub_domain_name: Optional[str] = rest_field( + name="customSubDomainName", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional subdomain name used for token-based authentication.""" + network_acls: Optional["_models.NetworkRuleSet"] = rest_field( + name="networkAcls", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of rules governing the accessibility from specific network locations.""" + encryption: Optional["_models.Encryption"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The encryption properties for this resource.""" + user_owned_storage: Optional[list["_models.UserOwnedStorage"]] = rest_field( + name="userOwnedStorage", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage accounts for this resource.""" + aml_workspace: Optional["_models.UserOwnedAmlWorkspace"] = rest_field( + name="amlWorkspace", visibility=["read", "create", "update", "delete", "query"] + ) + """The user owned AML account properties.""" + private_endpoint_connections: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( + name="privateEndpointConnections", visibility=["read"] + ) + """The private endpoint connection associated with the Cognitive Services account.""" + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether or not public endpoint access is allowed for this account. Known values are: + \"Enabled\" and \"Disabled\".""" + api_properties: Optional["_models.ApiProperties"] = rest_field( + name="apiProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """The api properties for special APIs.""" + date_created: Optional[str] = rest_field(name="dateCreated", visibility=["read"]) + """Gets the date of cognitive services account creation.""" + call_rate_limit: Optional["_models.CallRateLimit"] = rest_field(name="callRateLimit", visibility=["read"]) + """The call rate limit Cognitive Services account.""" + dynamic_throttling_enabled: Optional[bool] = rest_field( + name="dynamicThrottlingEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """The flag to enable dynamic throttling.""" + stored_completions_disabled: Optional[bool] = rest_field( + name="storedCompletionsDisabled", visibility=["read", "create", "update", "delete", "query"] + ) + """The flag to disable stored completions.""" + quota_limit: Optional["_models.QuotaLimit"] = rest_field(name="quotaLimit", visibility=["read"]) + restrict_outbound_network_access: Optional[bool] = rest_field( + name="restrictOutboundNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + allowed_fqdn_list: Optional[list[str]] = rest_field( + name="allowedFqdnList", visibility=["read", "create", "update", "delete", "query"] + ) + disable_local_auth: Optional[bool] = rest_field( + name="disableLocalAuth", visibility=["read", "create", "update", "delete", "query"] + ) + endpoints: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Dictionary of .""" + restore: Optional[bool] = rest_field(visibility=["create", "update"]) + deletion_date: Optional[str] = rest_field(name="deletionDate", visibility=["read"]) + """The deletion date, only available for deleted account.""" + scheduled_purge_date: Optional[str] = rest_field(name="scheduledPurgeDate", visibility=["read"]) + """The scheduled purge date, only available for deleted account.""" + locations: Optional["_models.MultiRegionSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The multiregion settings of Cognitive Services account.""" + commitment_plan_associations: Optional[list["_models.CommitmentPlanAssociation"]] = rest_field( + name="commitmentPlanAssociations", visibility=["read"] + ) + """The commitment plan associations of Cognitive Services account.""" + abuse_penalty: Optional["_models.AbusePenalty"] = rest_field(name="abusePenalty", visibility=["read"]) + """The abuse penalty.""" + rai_monitor_config: Optional["_models.RaiMonitorConfig"] = rest_field( + name="raiMonitorConfig", visibility=["read", "create", "update", "delete", "query"] + ) + """Cognitive Services Rai Monitor Config.""" + network_injections: Optional[list["_models.NetworkInjection"]] = rest_field( + name="networkInjections", visibility=["read", "create", "update", "delete", "query"] + ) + allow_project_management: Optional[bool] = rest_field( + name="allowProjectManagement", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether this resource support project management as child resources, used as + containers for access management, data isolation and cost in AI Foundry.""" + default_project: Optional[str] = rest_field( + name="defaultProject", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the project, by project name, that is targeted when data plane endpoints are called + without a project parameter.""" + associated_projects: Optional[list[str]] = rest_field( + name="associatedProjects", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the projects, by project name, that are associated with this resource.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + migration_token: Optional[str] = None, + custom_sub_domain_name: Optional[str] = None, + network_acls: Optional["_models.NetworkRuleSet"] = None, + encryption: Optional["_models.Encryption"] = None, + user_owned_storage: Optional[list["_models.UserOwnedStorage"]] = None, + aml_workspace: Optional["_models.UserOwnedAmlWorkspace"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + api_properties: Optional["_models.ApiProperties"] = None, + dynamic_throttling_enabled: Optional[bool] = None, + stored_completions_disabled: Optional[bool] = None, + restrict_outbound_network_access: Optional[bool] = None, + allowed_fqdn_list: Optional[list[str]] = None, + disable_local_auth: Optional[bool] = None, + restore: Optional[bool] = None, + locations: Optional["_models.MultiRegionSettings"] = None, + rai_monitor_config: Optional["_models.RaiMonitorConfig"] = None, + network_injections: Optional[list["_models.NetworkInjection"]] = None, + allow_project_management: Optional[bool] = None, + default_project: Optional[str] = None, + associated_projects: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccountSku(_Model): + """Cognitive Services resource type and SKU. + + :ivar resource_type: Resource Namespace and Type. + :vartype resource_type: str + :ivar sku: The SKU of Cognitive Services account. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + """ + + resource_type: Optional[str] = rest_field( + name="resourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource Namespace and Type.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU of Cognitive Services account.""" + + @overload + def __init__( + self, + *, + resource_type: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccountSkuListResult(_Model): + """The list of cognitive services accounts operation response. + + :ivar value: Gets the list of Cognitive Services accounts and their properties. + :vartype value: list[~azure.mgmt.cognitiveservices.models.AccountSku] + """ + + value: Optional[list["_models.AccountSku"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets the list of Cognitive Services accounts and their properties.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.AccountSku"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + """ + + +class AgentApplication(ProxyResource): + """Agent Application resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: [Required] Additional attributes of the entity. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.AgenticApplicationProperties + """ + + properties: "_models.AgenticApplicationProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """[Required] Additional attributes of the entity. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.AgenticApplicationProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentDeployment(ProxyResource): + """Agent Deployment resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: [Required] Additional attributes of the entity. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.AgentDeploymentProperties + """ + + properties: "_models.AgentDeploymentProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """[Required] Additional attributes of the entity. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.AgentDeploymentProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceBase(_Model): + """ResourceBase. + + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The asset description text.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Tag dictionary. Tags can be added, removed, and updated.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentDeploymentProperties(ResourceBase): + """Type representing an agent deployment as a management construct. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + HostedAgentDeployment, ManagedAgentDeployment + + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar display_name: Gets or sets the display name of the deployment. + :vartype display_name: str + :ivar deployment_id: Gets or sets the unique identifier of the deployment. + :vartype deployment_id: str + :ivar state: Gets or sets the current operational state of the deployment (and, intrinsically, + of the comprising agents). Known values are: "Starting", "Running", "Stopping", "Stopped", + "Failed", "Deleting", "Deleted", and "Updating". + :vartype state: str or ~azure.mgmt.cognitiveservices.models.AgentDeploymentState + :ivar protocols: Gets or sets the supported protocol types and versions exposed by this + deployment. + :vartype protocols: list[~azure.mgmt.cognitiveservices.models.AgentProtocolVersion] + :ivar agents: Returns a flat list of agent:version deployed in this deployment. + :vartype agents: list[~azure.mgmt.cognitiveservices.models.VersionedAgentReference] + :ivar deployment_type: Gets or sets the type of deployment for the agent. Required. Known + values are: "Managed", "Hosted", and "Custom". + :vartype deployment_type: str or ~azure.mgmt.cognitiveservices.models.AgentDeploymentType + :ivar provisioning_state: Gets or sets the provisioning state of the agent deployment. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.AgentDeploymentProvisioningState + """ + + __mapping__: dict[str, _Model] = {} + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the display name of the deployment.""" + deployment_id: Optional[str] = rest_field( + name="deploymentId", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the unique identifier of the deployment.""" + state: Optional[Union[str, "_models.AgentDeploymentState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the current operational state of the deployment (and, intrinsically, of the + comprising agents). Known values are: \"Starting\", \"Running\", \"Stopping\", \"Stopped\", + \"Failed\", \"Deleting\", \"Deleted\", and \"Updating\".""" + protocols: Optional[list["_models.AgentProtocolVersion"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the supported protocol types and versions exposed by this deployment.""" + agents: Optional[list["_models.VersionedAgentReference"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Returns a flat list of agent:version deployed in this deployment.""" + deployment_type: str = rest_discriminator( + name="deploymentType", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the type of deployment for the agent. Required. Known values are: \"Managed\", + \"Hosted\", and \"Custom\".""" + provisioning_state: Optional[Union[str, "_models.AgentDeploymentProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Gets or sets the provisioning state of the agent deployment. Known values are: \"Succeeded\", + \"Failed\", \"Canceled\", \"Creating\", \"Updating\", and \"Deleting\".""" + + @overload + def __init__( + self, + *, + deployment_type: str, + description: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + display_name: Optional[str] = None, + deployment_id: Optional[str] = None, + state: Optional[Union[str, "_models.AgentDeploymentState"]] = None, + protocols: Optional[list["_models.AgentProtocolVersion"]] = None, + agents: Optional[list["_models.VersionedAgentReference"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgenticApplicationProperties(ResourceBase): + """Resource type representing an agentic application as a management construct. + + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar display_name: The display name of the application. + :vartype display_name: str + :ivar base_url: The application's dedicated invocation endpoint. + :vartype base_url: str + :ivar agents: The list of agent definitions comprising this application, returned as references + to the objects under the parent project; use this to obtain a flat list of all agent-version + pairs represented by this application. + :vartype agents: list[~azure.mgmt.cognitiveservices.models.AgentReferenceProperties] + :ivar agent_identity_blueprint: The EntraId Agentic Blueprint of the application. + :vartype agent_identity_blueprint: ~azure.mgmt.cognitiveservices.models.AssignedIdentity + :ivar default_instance_identity: The (default) agent instance identity of the application. + :vartype default_instance_identity: ~azure.mgmt.cognitiveservices.models.AssignedIdentity + :ivar authorization_policy: Gets or sets the authorization policy associated with this agentic + application instance. + :vartype authorization_policy: + ~azure.mgmt.cognitiveservices.models.ApplicationAuthorizationPolicy + :ivar traffic_routing_policy: Gets or sets the traffic routing policy for the application's + deployments. + :vartype traffic_routing_policy: + ~azure.mgmt.cognitiveservices.models.ApplicationTrafficRoutingPolicy + :ivar provisioning_state: Provisioning state of the application. Known values are: "Succeeded", + "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.AgenticApplicationProvisioningState + :ivar is_enabled: Enabledstate of the application. + :vartype is_enabled: bool + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The display name of the application.""" + base_url: Optional[str] = rest_field(name="baseUrl", visibility=["read", "create", "update", "delete", "query"]) + """The application's dedicated invocation endpoint.""" + agents: Optional[list["_models.AgentReferenceProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of agent definitions comprising this application, returned as references to the + objects under the parent project; use this to obtain a flat list of all agent-version pairs + represented by this application.""" + agent_identity_blueprint: Optional["_models.AssignedIdentity"] = rest_field( + name="agentIdentityBlueprint", visibility=["read", "create", "update", "delete", "query"] + ) + """The EntraId Agentic Blueprint of the application.""" + default_instance_identity: Optional["_models.AssignedIdentity"] = rest_field( + name="defaultInstanceIdentity", visibility=["read", "create", "update", "delete", "query"] + ) + """The (default) agent instance identity of the application.""" + authorization_policy: Optional["_models.ApplicationAuthorizationPolicy"] = rest_field( + name="authorizationPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the authorization policy associated with this agentic application instance.""" + traffic_routing_policy: Optional["_models.ApplicationTrafficRoutingPolicy"] = rest_field( + name="trafficRoutingPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the traffic routing policy for the application's deployments.""" + provisioning_state: Optional[Union[str, "_models.AgenticApplicationProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the application. Known values are: \"Succeeded\", \"Failed\", + \"Canceled\", \"Creating\", \"Updating\", and \"Deleting\".""" + is_enabled: Optional[bool] = rest_field(name="isEnabled", visibility=["read"]) + """Enabledstate of the application.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + display_name: Optional[str] = None, + base_url: Optional[str] = None, + agents: Optional[list["_models.AgentReferenceProperties"]] = None, + agent_identity_blueprint: Optional["_models.AssignedIdentity"] = None, + default_instance_identity: Optional["_models.AssignedIdentity"] = None, + authorization_policy: Optional["_models.ApplicationAuthorizationPolicy"] = None, + traffic_routing_policy: Optional["_models.ApplicationTrafficRoutingPolicy"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentProtocolVersion(_Model): + """Type modeling the protocol and version used by an agent/exposed by a deployment. + + :ivar protocol: The protocol used by the agent/exposed by a deployment. Known values are: + "Agent", "A2A", and "Responses". + :vartype protocol: str or ~azure.mgmt.cognitiveservices.models.AgentProtocol + :ivar version: The version of the protocol. + :vartype version: str + """ + + protocol: Optional[Union[str, "_models.AgentProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The protocol used by the agent/exposed by a deployment. Known values are: \"Agent\", \"A2A\", + and \"Responses\".""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The version of the protocol.""" + + @overload + def __init__( + self, + *, + protocol: Optional[Union[str, "_models.AgentProtocol"]] = None, + version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentReference(ProxyResource): + """Agent Reference resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: [Required] Additional attributes of the entity. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.AgentReferenceProperties + """ + + properties: "_models.AgentReferenceProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """[Required] Additional attributes of the entity. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.AgentReferenceProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentReferenceProperties(_Model): + """Type modeling a reference to a version of an agent definition. + + :ivar agent_id: Gets the agent's unique identifier within the organization (subscription). + :vartype agent_id: str + :ivar agent_name: Gets the agent's name (unique within the project/app). + :vartype agent_name: str + """ + + agent_id: Optional[str] = rest_field(name="agentId", visibility=["read", "create", "update", "delete", "query"]) + """Gets the agent's unique identifier within the organization (subscription).""" + agent_name: Optional[str] = rest_field(name="agentName", visibility=["read", "create", "update", "delete", "query"]) + """Gets the agent's name (unique within the project/app).""" + + @overload + def __init__( + self, + *, + agent_id: Optional[str] = None, + agent_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentReferenceResourceArmPaginatedResult(_Model): + """A paginated list of Agent Reference entities. + + :ivar next_link: The link to the next page of Agent Reference objects. If null, there are no + additional pages. + :vartype next_link: str + :ivar value: An array of objects of type Agent Reference. + :vartype value: list[~azure.mgmt.cognitiveservices.models.AgentReference] + """ + + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link to the next page of Agent Reference objects. If null, there are no additional pages.""" + value: Optional[list["_models.AgentReference"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """An array of objects of type Agent Reference.""" + + @overload + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[list["_models.AgentReference"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiKeyAuthConnectionProperties(ConnectionPropertiesV2, discriminator="ApiKey"): + """This connection type covers the generic ApiKey auth connection categories, for examples: + AzureOpenAI: + Category:= AzureOpenAI + AuthType:= ApiKey (as type discriminator) + Credentials:= {ApiKey} as .ApiKey + Target:= {ApiBase} + + CognitiveService: + Category:= CognitiveService + AuthType:= ApiKey (as type discriminator) + Credentials:= {SubscriptionKey} as ApiKey + Target:= ServiceRegion={serviceRegion} + + CognitiveSearch: + Category:= CognitiveSearch + AuthType:= ApiKey (as type discriminator) + Credentials:= {Key} as ApiKey + Target:= {Endpoint} + + Use Metadata property bag for ApiType, ApiVersion, Kind and other metadata fields. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: Api key object for connection credential. + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionApiKey + :ivar auth_type: Authentication type of the connection target. Required. API_KEY. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.API_KEY + """ + + credentials: Optional["_models.ConnectionApiKey"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Api key object for connection credential.""" + auth_type: Literal[ConnectionAuthType.API_KEY] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. API_KEY.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionApiKey"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.API_KEY # type: ignore + + +class ApiKeys(_Model): + """The access keys for the cognitive services account. + + :ivar key1: Gets the value of key 1. + :vartype key1: str + :ivar key2: Gets the value of key 2. + :vartype key2: str + """ + + key1: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets the value of key 1.""" + key2: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets the value of key 2.""" + + @overload + def __init__( + self, + *, + key1: Optional[str] = None, + key2: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiProperties(_Model): + """The api properties for special APIs. + + :ivar qna_runtime_endpoint: (QnAMaker Only) The runtime endpoint of QnAMaker. + :vartype qna_runtime_endpoint: str + :ivar qna_azure_search_endpoint_key: (QnAMaker Only) The Azure Search endpoint key of QnAMaker. + :vartype qna_azure_search_endpoint_key: str + :ivar qna_azure_search_endpoint_id: (QnAMaker Only) The Azure Search endpoint id of QnAMaker. + :vartype qna_azure_search_endpoint_id: str + :ivar statistics_enabled: (Bing Search Only) The flag to enable statistics of Bing Search. + :vartype statistics_enabled: bool + :ivar event_hub_connection_string: (Personalization Only) The flag to enable statistics of Bing + Search. + :vartype event_hub_connection_string: str + :ivar storage_account_connection_string: (Personalization Only) The storage account connection + string. + :vartype storage_account_connection_string: str + :ivar aad_client_id: (Metrics Advisor Only) The Azure AD Client Id (Application Id). + :vartype aad_client_id: str + :ivar aad_tenant_id: (Metrics Advisor Only) The Azure AD Tenant Id. + :vartype aad_tenant_id: str + :ivar super_user: (Metrics Advisor Only) The super user of Metrics Advisor. + :vartype super_user: str + :ivar website_name: (Metrics Advisor Only) The website name of Metrics Advisor. + :vartype website_name: str + """ + + qna_runtime_endpoint: Optional[str] = rest_field( + name="qnaRuntimeEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """(QnAMaker Only) The runtime endpoint of QnAMaker.""" + qna_azure_search_endpoint_key: Optional[str] = rest_field( + name="qnaAzureSearchEndpointKey", visibility=["read", "create", "update", "delete", "query"] + ) + """(QnAMaker Only) The Azure Search endpoint key of QnAMaker.""" + qna_azure_search_endpoint_id: Optional[str] = rest_field( + name="qnaAzureSearchEndpointId", visibility=["read", "create", "update", "delete", "query"] + ) + """(QnAMaker Only) The Azure Search endpoint id of QnAMaker.""" + statistics_enabled: Optional[bool] = rest_field( + name="statisticsEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """(Bing Search Only) The flag to enable statistics of Bing Search.""" + event_hub_connection_string: Optional[str] = rest_field( + name="eventHubConnectionString", visibility=["read", "create", "update", "delete", "query"] + ) + """(Personalization Only) The flag to enable statistics of Bing Search.""" + storage_account_connection_string: Optional[str] = rest_field( + name="storageAccountConnectionString", visibility=["read", "create", "update", "delete", "query"] + ) + """(Personalization Only) The storage account connection string.""" + aad_client_id: Optional[str] = rest_field( + name="aadClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """(Metrics Advisor Only) The Azure AD Client Id (Application Id).""" + aad_tenant_id: Optional[str] = rest_field( + name="aadTenantId", visibility=["read", "create", "update", "delete", "query"] + ) + """(Metrics Advisor Only) The Azure AD Tenant Id.""" + super_user: Optional[str] = rest_field(name="superUser", visibility=["read", "create", "update", "delete", "query"]) + """(Metrics Advisor Only) The super user of Metrics Advisor.""" + website_name: Optional[str] = rest_field( + name="websiteName", visibility=["read", "create", "update", "delete", "query"] + ) + """(Metrics Advisor Only) The website name of Metrics Advisor.""" + + @overload + def __init__( + self, + *, + qna_runtime_endpoint: Optional[str] = None, + qna_azure_search_endpoint_key: Optional[str] = None, + qna_azure_search_endpoint_id: Optional[str] = None, + statistics_enabled: Optional[bool] = None, + event_hub_connection_string: Optional[str] = None, + storage_account_connection_string: Optional[str] = None, + aad_client_id: Optional[str] = None, + aad_tenant_id: Optional[str] = None, + super_user: Optional[str] = None, + website_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationAuthorizationPolicy(_Model): + """Represents a policy for authorizing applications based on specified authentication and + authorization schemes. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ChannelsBuiltInAuthorizationPolicy, RoleBasedBuiltInAuthorizationPolicy, + OrganizationSharedBuiltInAuthorizationPolicy + + :ivar type: Authorization scheme type. Required. Known values are: "Default", + "OrganizationScope", "Channels", and "Custom". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.BuiltInAuthorizationScheme + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Authorization scheme type. Required. Known values are: \"Default\", \"OrganizationScope\", + \"Channels\", and \"Custom\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApplicationTrafficRoutingPolicy(_Model): + """Type representing an application traffic policy as a property of an agentic application. + + :ivar protocol: Methodology used to route traffic to the application's deployments. + "FixedRatio" + :vartype protocol: str or ~azure.mgmt.cognitiveservices.models.TrafficRoutingProtocol + :ivar rules: Gets or sets the collection of traffic routing rules. + :vartype rules: list[~azure.mgmt.cognitiveservices.models.TrafficRoutingRule] + """ + + protocol: Optional[Union[str, "_models.TrafficRoutingProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Methodology used to route traffic to the application's deployments. \"FixedRatio\"""" + rules: Optional[list["_models.TrafficRoutingRule"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the collection of traffic routing rules.""" + + @overload + def __init__( + self, + *, + protocol: Optional[Union[str, "_models.TrafficRoutingProtocol"]] = None, + rules: Optional[list["_models.TrafficRoutingRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AssignedIdentity(_Model): + """Type representing an identity assignment. + + :ivar kind: Specifies the kind of Entra identity described by this object. Required. Known + values are: "AgentBlueprint", "AgentInstance", "AgenticUser", "Managed", and "None". + :vartype kind: str or ~azure.mgmt.cognitiveservices.models.IdentityKind + :ivar type: Enumeration of identity types, from the perspective of management. Required. Known + values are: "System", "User", and "None". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.IdentityManagementType + :ivar client_id: The client ID of the identity. Required. + :vartype client_id: str + :ivar principal_id: The principal ID of the identity. Required. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the identity. Required. + :vartype tenant_id: str + :ivar subject: The subject of this identity assignment. + :vartype subject: str + :ivar provisioning_state: Represents the provisioning state of an identity resource. Known + values are: "Creating", "Updating", "Succeeded", "Failed", "Canceled", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.IdentityProvisioningState + """ + + kind: Union[str, "_models.IdentityKind"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Specifies the kind of Entra identity described by this object. Required. Known values are: + \"AgentBlueprint\", \"AgentInstance\", \"AgenticUser\", \"Managed\", and \"None\".""" + type: Union[str, "_models.IdentityManagementType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Enumeration of identity types, from the perspective of management. Required. Known values are: + \"System\", \"User\", and \"None\".""" + client_id: str = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """The client ID of the identity. Required.""" + principal_id: str = rest_field(name="principalId", visibility=["read", "create", "update", "delete", "query"]) + """The principal ID of the identity. Required.""" + tenant_id: str = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The tenant ID of the identity. Required.""" + subject: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The subject of this identity assignment.""" + provisioning_state: Optional[Union[str, "_models.IdentityProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Represents the provisioning state of an identity resource. Known values are: \"Creating\", + \"Updating\", \"Succeeded\", \"Failed\", \"Canceled\", and \"Deleting\".""" + + @overload + def __init__( + self, + *, + kind: Union[str, "_models.IdentityKind"], + type: Union[str, "_models.IdentityManagementType"], + client_id: str, + principal_id: str, + tenant_id: str, + subject: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BillingMeterInfo(_Model): + """BillingMeterInfo. + + :ivar name: + :vartype name: str + :ivar meter_id: + :vartype meter_id: str + :ivar unit: + :vartype unit: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + meter_id: Optional[str] = rest_field(name="meterId", visibility=["read", "create", "update", "delete", "query"]) + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + meter_id: Optional[str] = None, + unit: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CalculateModelCapacityParameter(_Model): + """Calculate Model Capacity parameter. + + :ivar model: Properties of Cognitive Services account deployment model. + :vartype model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar sku_name: The name of SKU. + :vartype sku_name: str + :ivar workloads: List of Model Capacity Calculator Workload. + :vartype workloads: list[~azure.mgmt.cognitiveservices.models.ModelCapacityCalculatorWorkload] + """ + + model: Optional["_models.DeploymentModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Cognitive Services account deployment model.""" + sku_name: Optional[str] = rest_field(name="skuName", visibility=["read", "create", "update", "delete", "query"]) + """The name of SKU.""" + workloads: Optional[list["_models.ModelCapacityCalculatorWorkload"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of Model Capacity Calculator Workload.""" + + @overload + def __init__( + self, + *, + model: Optional["_models.DeploymentModel"] = None, + sku_name: Optional[str] = None, + workloads: Optional[list["_models.ModelCapacityCalculatorWorkload"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CalculateModelCapacityResult(_Model): + """Calculate Model Capacity result. + + :ivar model: Properties of Cognitive Services account deployment model. + :vartype model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar sku_name: + :vartype sku_name: str + :ivar estimated_capacity: Model Estimated Capacity. + :vartype estimated_capacity: + ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResultEstimatedCapacity + """ + + model: Optional["_models.DeploymentModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Cognitive Services account deployment model.""" + sku_name: Optional[str] = rest_field(name="skuName", visibility=["read", "create", "update", "delete", "query"]) + estimated_capacity: Optional["_models.CalculateModelCapacityResultEstimatedCapacity"] = rest_field( + name="estimatedCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """Model Estimated Capacity.""" + + @overload + def __init__( + self, + *, + model: Optional["_models.DeploymentModel"] = None, + sku_name: Optional[str] = None, + estimated_capacity: Optional["_models.CalculateModelCapacityResultEstimatedCapacity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CalculateModelCapacityResultEstimatedCapacity(_Model): # pylint: disable=name-too-long + """Model Estimated Capacity. + + :ivar value: + :vartype value: int + :ivar deployable_value: + :vartype deployable_value: int + """ + + value: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + deployable_value: Optional[int] = rest_field( + name="deployableValue", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + value: Optional[int] = None, + deployable_value: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CallRateLimit(_Model): + """The call rate limit Cognitive Services account. + + :ivar count: The count value of Call Rate Limit. + :vartype count: float + :ivar renewal_period: The renewal period in seconds of Call Rate Limit. + :vartype renewal_period: float + :ivar rules: + :vartype rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + """ + + count: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The count value of Call Rate Limit.""" + renewal_period: Optional[float] = rest_field( + name="renewalPeriod", visibility=["read", "create", "update", "delete", "query"] + ) + """The renewal period in seconds of Call Rate Limit.""" + rules: Optional[list["_models.ThrottlingRule"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + count: Optional[float] = None, + renewal_period: Optional[float] = None, + rules: Optional[list["_models.ThrottlingRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CapabilityHost(ProxyResource): + """Azure Resource Manager resource envelope. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: [Required] Additional attributes of the entity. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.CapabilityHostProperties + """ + + properties: "_models.CapabilityHostProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """[Required] Additional attributes of the entity. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.CapabilityHostProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CapabilityHostProperties(ResourceBase): + """CapabilityHostProperties. + + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar ai_services_connections: List of AI services connections. + :vartype ai_services_connections: list[str] + :ivar capability_host_kind: Kind of this capability host. "Agents" + :vartype capability_host_kind: str or ~azure.mgmt.cognitiveservices.models.CapabilityHostKind + :ivar customer_subnet: Customer subnet info to help set up this capability host. + :vartype customer_subnet: str + :ivar provisioning_state: Provisioning state for the CapabilityHost. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.CapabilityHostProvisioningState + :ivar storage_connections: List of connection names from those available in the account or + project to be used as a storage resource. + :vartype storage_connections: list[str] + :ivar thread_storage_connections: List of connection names from those available in the account + or project to be used for Thread storage. + :vartype thread_storage_connections: list[str] + :ivar vector_store_connections: List of connection names from those available in the account or + project to be used for vector database (e.g. CosmosDB). + :vartype vector_store_connections: list[str] + :ivar enable_public_hosting_environment: Whether public hosting environment is enabled for the + capability host. + :vartype enable_public_hosting_environment: bool + """ + + ai_services_connections: Optional[list[str]] = rest_field( + name="aiServicesConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of AI services connections.""" + capability_host_kind: Optional[Union[str, "_models.CapabilityHostKind"]] = rest_field( + name="capabilityHostKind", visibility=["read", "create", "update", "delete", "query"] + ) + """Kind of this capability host. \"Agents\"""" + customer_subnet: Optional[str] = rest_field( + name="customerSubnet", visibility=["read", "create", "update", "delete", "query"] + ) + """Customer subnet info to help set up this capability host.""" + provisioning_state: Optional[Union[str, "_models.CapabilityHostProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state for the CapabilityHost. Known values are: \"Succeeded\", \"Failed\", + \"Canceled\", \"Creating\", \"Updating\", and \"Deleting\".""" + storage_connections: Optional[list[str]] = rest_field( + name="storageConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of connection names from those available in the account or project to be used as a storage + resource.""" + thread_storage_connections: Optional[list[str]] = rest_field( + name="threadStorageConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of connection names from those available in the account or project to be used for Thread + storage.""" + vector_store_connections: Optional[list[str]] = rest_field( + name="vectorStoreConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of connection names from those available in the account or project to be used for vector + database (e.g. CosmosDB).""" + enable_public_hosting_environment: Optional[bool] = rest_field( + name="enablePublicHostingEnvironment", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether public hosting environment is enabled for the capability host.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + ai_services_connections: Optional[list[str]] = None, + capability_host_kind: Optional[Union[str, "_models.CapabilityHostKind"]] = None, + customer_subnet: Optional[str] = None, + storage_connections: Optional[list[str]] = None, + thread_storage_connections: Optional[list[str]] = None, + vector_store_connections: Optional[list[str]] = None, + enable_public_hosting_environment: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CapacityConfig(_Model): + """The capacity configuration. + + :ivar minimum: The minimum capacity. + :vartype minimum: int + :ivar maximum: The maximum capacity. + :vartype maximum: int + :ivar step: The minimal incremental between allowed values for capacity. + :vartype step: int + :ivar default: The default capacity. + :vartype default: int + :ivar allowed_values: The array of allowed values for capacity. + :vartype allowed_values: list[int] + """ + + minimum: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The minimum capacity.""" + maximum: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum capacity.""" + step: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The minimal incremental between allowed values for capacity.""" + default: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The default capacity.""" + allowed_values: Optional[list[int]] = rest_field( + name="allowedValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The array of allowed values for capacity.""" + + @overload + def __init__( + self, + *, + minimum: Optional[int] = None, + maximum: Optional[int] = None, + step: Optional[int] = None, + default: Optional[int] = None, + allowed_values: Optional[list[int]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ChannelsBuiltInAuthorizationPolicy(ApplicationAuthorizationPolicy, discriminator="Channels"): + """Represents a built-in authorization policy specific to Azure Bot Service/Channels + authentication. + + :ivar type: Authorization scheme type. Required. Channels-specific (AzureBotService) + authorization. + :vartype type: str or ~azure.mgmt.cognitiveservices.models.CHANNELS + """ + + type: Literal[BuiltInAuthorizationScheme.CHANNELS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authorization scheme type. Required. Channels-specific (AzureBotService) authorization.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = BuiltInAuthorizationScheme.CHANNELS # type: ignore + + +class CheckDomainAvailabilityParameter(_Model): + """Check Domain availability parameter. + + :ivar subdomain_name: The subdomain name to use. Required. + :vartype subdomain_name: str + :ivar type: The Type of the resource. Required. + :vartype type: str + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + """ + + subdomain_name: str = rest_field(name="subdomainName", visibility=["read", "create", "update", "delete", "query"]) + """The subdomain name to use. Required.""" + type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Type of the resource. Required.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + + @overload + def __init__( + self, + *, + subdomain_name: str, + type: str, + kind: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckSkuAvailabilityParameter(_Model): + """Check SKU availability parameter. + + :ivar skus: The SKU of the resource. Required. + :vartype skus: list[str] + :ivar kind: The kind (type) of cognitive service account. Required. + :vartype kind: str + :ivar type: The Type of the resource. Required. + :vartype type: str + """ + + skus: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU of the resource. Required.""" + kind: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account. Required.""" + type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Type of the resource. Required.""" + + @overload + def __init__( + self, + *, + skus: list[str], + kind: str, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentCost(_Model): + """Cognitive Services account commitment cost. + + :ivar commitment_meter_id: Commitment meter Id. + :vartype commitment_meter_id: str + :ivar overage_meter_id: Overage meter Id. + :vartype overage_meter_id: str + """ + + commitment_meter_id: Optional[str] = rest_field( + name="commitmentMeterId", visibility=["read", "create", "update", "delete", "query"] + ) + """Commitment meter Id.""" + overage_meter_id: Optional[str] = rest_field( + name="overageMeterId", visibility=["read", "create", "update", "delete", "query"] + ) + """Overage meter Id.""" + + @overload + def __init__( + self, + *, + commitment_meter_id: Optional[str] = None, + overage_meter_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentPeriod(_Model): + """Cognitive Services account commitment period. + + :ivar tier: Commitment period commitment tier. + :vartype tier: str + :ivar count: Commitment period commitment count. + :vartype count: int + :ivar quota: Cognitive Services account commitment quota. + :vartype quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota + :ivar start_date: Commitment period start date. + :vartype start_date: str + :ivar end_date: Commitment period end date. + :vartype end_date: str + """ + + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Commitment period commitment tier.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Commitment period commitment count.""" + quota: Optional["_models.CommitmentQuota"] = rest_field(visibility=["read"]) + """Cognitive Services account commitment quota.""" + start_date: Optional[str] = rest_field(name="startDate", visibility=["read"]) + """Commitment period start date.""" + end_date: Optional[str] = rest_field(name="endDate", visibility=["read"]) + """Commitment period end date.""" + + @overload + def __init__( + self, + *, + tier: Optional[str] = None, + count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentPlan(Resource): + """Cognitive Services account commitment plan. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services account commitment plan. + :vartype properties: ~azure.mgmt.cognitiveservices.models.CommitmentPlanProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + """ + + properties: Optional["_models.CommitmentPlanProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services account commitment plan.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource model definition representing SKU.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.CommitmentPlanProperties"] = None, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + kind: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentPlanAccountAssociation(ProxyResource): + """The commitment plan association. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services account commitment plan association. + :vartype properties: + ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociationProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.CommitmentPlanAccountAssociationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services account commitment plan association.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + __flattened_items = ["account_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CommitmentPlanAccountAssociationProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CommitmentPlanAccountAssociationProperties(_Model): # pylint: disable=name-too-long + """The commitment plan account association properties. + + :ivar account_id: The Azure resource id of the account. + :vartype account_id: str + """ + + account_id: Optional[str] = rest_field(name="accountId", visibility=["read", "create", "update", "delete", "query"]) + """The Azure resource id of the account.""" + + @overload + def __init__( + self, + *, + account_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentPlanAssociation(_Model): + """The commitment plan association. + + :ivar commitment_plan_id: The Azure resource id of the commitment plan. + :vartype commitment_plan_id: str + :ivar commitment_plan_location: The location of of the commitment plan. + :vartype commitment_plan_location: str + """ + + commitment_plan_id: Optional[str] = rest_field( + name="commitmentPlanId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Azure resource id of the commitment plan.""" + commitment_plan_location: Optional[str] = rest_field( + name="commitmentPlanLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """The location of of the commitment plan.""" + + @overload + def __init__( + self, + *, + commitment_plan_id: Optional[str] = None, + commitment_plan_location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentPlanProperties(_Model): + """Properties of Cognitive Services account commitment plan. + + :ivar provisioning_state: Gets the status of the resource at the time the operation was called. + Known values are: "Accepted", "Creating", "Deleting", "Moving", "Failed", "Succeeded", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.CommitmentPlanProvisioningState + :ivar commitment_plan_guid: Commitment plan guid. + :vartype commitment_plan_guid: str + :ivar hosting_model: Account hosting model. Known values are: "Web", "ConnectedContainer", + "DisconnectedContainer", and "ProvisionedWeb". + :vartype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel + :ivar plan_type: Commitment plan type. + :vartype plan_type: str + :ivar current: Cognitive Services account commitment period. + :vartype current: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + :ivar auto_renew: AutoRenew commitment plan. + :vartype auto_renew: bool + :ivar next: Cognitive Services account commitment period. + :vartype next: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + :ivar last: Cognitive Services account commitment period. + :vartype last: ~azure.mgmt.cognitiveservices.models.CommitmentPeriod + :ivar provisioning_issues: The list of ProvisioningIssue. + :vartype provisioning_issues: list[str] + """ + + provisioning_state: Optional[Union[str, "_models.CommitmentPlanProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Gets the status of the resource at the time the operation was called. Known values are: + \"Accepted\", \"Creating\", \"Deleting\", \"Moving\", \"Failed\", \"Succeeded\", and + \"Canceled\".""" + commitment_plan_guid: Optional[str] = rest_field( + name="commitmentPlanGuid", visibility=["read", "create", "update", "delete", "query"] + ) + """Commitment plan guid.""" + hosting_model: Optional[Union[str, "_models.HostingModel"]] = rest_field( + name="hostingModel", visibility=["read", "create", "update", "delete", "query"] + ) + """Account hosting model. Known values are: \"Web\", \"ConnectedContainer\", + \"DisconnectedContainer\", and \"ProvisionedWeb\".""" + plan_type: Optional[str] = rest_field(name="planType", visibility=["read", "create", "update", "delete", "query"]) + """Commitment plan type.""" + current: Optional["_models.CommitmentPeriod"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Cognitive Services account commitment period.""" + auto_renew: Optional[bool] = rest_field( + name="autoRenew", visibility=["read", "create", "update", "delete", "query"] + ) + """AutoRenew commitment plan.""" + next: Optional["_models.CommitmentPeriod"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cognitive Services account commitment period.""" + last: Optional["_models.CommitmentPeriod"] = rest_field(visibility=["read"]) + """Cognitive Services account commitment period.""" + provisioning_issues: Optional[list[str]] = rest_field(name="provisioningIssues", visibility=["read"]) + """The list of ProvisioningIssue.""" + + @overload + def __init__( + self, + *, + commitment_plan_guid: Optional[str] = None, + hosting_model: Optional[Union[str, "_models.HostingModel"]] = None, + plan_type: Optional[str] = None, + current: Optional["_models.CommitmentPeriod"] = None, + auto_renew: Optional[bool] = None, + next: Optional["_models.CommitmentPeriod"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentQuota(_Model): + """Cognitive Services account commitment quota. + + :ivar quantity: Commitment quota quantity. + :vartype quantity: int + :ivar unit: Commitment quota unit. + :vartype unit: str + """ + + quantity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Commitment quota quantity.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Commitment quota unit.""" + + @overload + def __init__( + self, + *, + quantity: Optional[int] = None, + unit: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CommitmentTier(_Model): + """Cognitive Services account commitment tier. + + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + :ivar sku_name: The name of the SKU. Ex - P3. It is typically a letter+number code. + :vartype sku_name: str + :ivar hosting_model: Account hosting model. Known values are: "Web", "ConnectedContainer", + "DisconnectedContainer", and "ProvisionedWeb". + :vartype hosting_model: str or ~azure.mgmt.cognitiveservices.models.HostingModel + :ivar plan_type: Commitment plan type. + :vartype plan_type: str + :ivar tier: Commitment period commitment tier. + :vartype tier: str + :ivar max_count: Commitment period commitment max count. + :vartype max_count: int + :ivar quota: Cognitive Services account commitment quota. + :vartype quota: ~azure.mgmt.cognitiveservices.models.CommitmentQuota + :ivar cost: Cognitive Services account commitment cost. + :vartype cost: ~azure.mgmt.cognitiveservices.models.CommitmentCost + """ + + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + sku_name: Optional[str] = rest_field(name="skuName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the SKU. Ex - P3. It is typically a letter+number code.""" + hosting_model: Optional[Union[str, "_models.HostingModel"]] = rest_field( + name="hostingModel", visibility=["read", "create", "update", "delete", "query"] + ) + """Account hosting model. Known values are: \"Web\", \"ConnectedContainer\", + \"DisconnectedContainer\", and \"ProvisionedWeb\".""" + plan_type: Optional[str] = rest_field(name="planType", visibility=["read", "create", "update", "delete", "query"]) + """Commitment plan type.""" + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Commitment period commitment tier.""" + max_count: Optional[int] = rest_field(name="maxCount", visibility=["read", "create", "update", "delete", "query"]) + """Commitment period commitment max count.""" + quota: Optional["_models.CommitmentQuota"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cognitive Services account commitment quota.""" + cost: Optional["_models.CommitmentCost"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cognitive Services account commitment cost.""" + + @overload + def __init__( + self, + *, + kind: Optional[str] = None, + sku_name: Optional[str] = None, + hosting_model: Optional[Union[str, "_models.HostingModel"]] = None, + plan_type: Optional[str] = None, + tier: Optional[str] = None, + max_count: Optional[int] = None, + quota: Optional["_models.CommitmentQuota"] = None, + cost: Optional["_models.CommitmentCost"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Compute(ProxyResource): + """Cognitive Services compute cluster resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services compute. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ComputeProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: "_models.ComputeProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Cognitive Services compute. Required.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: "_models.ComputeProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComputePatch(_Model): + """Patch model for compute resource updates. + + :ivar tags: Updated tags for the compute resource. + :vartype tags: dict[str, str] + :ivar properties: Partial update of compute properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ComputeProperties + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Updated tags for the compute resource.""" + properties: Optional["_models.ComputeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Partial update of compute properties.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ComputeProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComputeProperties(_Model): + """Properties of a compute resource. + + :ivar pools: Pools attached to this compute cluster. Required. + :vartype pools: list[~azure.mgmt.cognitiveservices.models.Pool] + :ivar subnet_arm_id: ARM ID of the subnet used for compute. + :vartype subnet_arm_id: str + :ivar provisioning_state: Provisioning state of the compute resource. Known values are: + "Accepted", "Succeeded", "Failed", "Canceled", "Deleting", "Scaling", and "Disabled". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.ComputeProvisioningState + :ivar errors: Error details for the compute resource. + :vartype errors: list[~azure.mgmt.cognitiveservices.models.RootError] + :ivar creation_time: Creation time of the compute resource. + :vartype creation_time: ~datetime.datetime + """ + + pools: list["_models.Pool"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Pools attached to this compute cluster. Required.""" + subnet_arm_id: Optional[str] = rest_field( + name="subnetArmId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM ID of the subnet used for compute.""" + provisioning_state: Optional[Union[str, "_models.ComputeProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the compute resource. Known values are: \"Accepted\", \"Succeeded\", + \"Failed\", \"Canceled\", \"Deleting\", \"Scaling\", and \"Disabled\".""" + errors: Optional[list["_models.RootError"]] = rest_field(visibility=["read"]) + """Error details for the compute resource.""" + creation_time: Optional[datetime.datetime] = rest_field(name="creationTime", visibility=["read"], format="rfc3339") + """Creation time of the compute resource.""" + + @overload + def __init__( + self, + *, + pools: list["_models.Pool"], + subnet_arm_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionAccessKey(_Model): + """ConnectionAccessKey. + + :ivar access_key_id: + :vartype access_key_id: str + :ivar secret_access_key: + :vartype secret_access_key: str + """ + + access_key_id: Optional[str] = rest_field( + name="accessKeyId", visibility=["read", "create", "update", "delete", "query"] + ) + secret_access_key: Optional[str] = rest_field( + name="secretAccessKey", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + access_key_id: Optional[str] = None, + secret_access_key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionAccountKey(_Model): + """Account key object for connection credential. + + :ivar key: + :vartype key: str + """ + + key: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionApiKey(_Model): + """Api key object for connection credential. + + :ivar key: + :vartype key: str + """ + + key: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionManagedIdentity(_Model): + """ConnectionManagedIdentity. + + :ivar client_id: + :vartype client_id: str + :ivar resource_id: + :vartype resource_id: str + """ + + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + client_id: Optional[str] = None, + resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionOAuth2(_Model): + """ClientId and ClientSecret are required. Other properties are optional depending on each OAuth2 + provider's implementation. + + :ivar auth_url: Required by Concur connection category. + :vartype auth_url: str + :ivar client_id: Client id in the format of UUID. + :vartype client_id: str + :ivar client_secret: + :vartype client_secret: str + :ivar developer_token: Required by GoogleAdWords connection category. + :vartype developer_token: str + :ivar password: + :vartype password: str + :ivar refresh_token: Required by GoogleBigQuery, GoogleAdWords, Hubspot, QuickBooks, Square, + Xero, Zoho where user needs to get RefreshToken offline. + :vartype refresh_token: str + :ivar tenant_id: Required by QuickBooks and Xero connection categories. + :vartype tenant_id: str + :ivar username: Concur, ServiceNow auth server AccessToken grant type is 'Password' which + requires UsernamePassword. + :vartype username: str + """ + + auth_url: Optional[str] = rest_field(name="authUrl", visibility=["read", "create", "update", "delete", "query"]) + """Required by Concur connection category.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client id in the format of UUID.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + developer_token: Optional[str] = rest_field( + name="developerToken", visibility=["read", "create", "update", "delete", "query"] + ) + """Required by GoogleAdWords connection category.""" + password: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + refresh_token: Optional[str] = rest_field( + name="refreshToken", visibility=["read", "create", "update", "delete", "query"] + ) + """Required by GoogleBigQuery, GoogleAdWords, Hubspot, QuickBooks, Square, Xero, Zoho where user + needs to get RefreshToken offline.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Required by QuickBooks and Xero connection categories.""" + username: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Concur, ServiceNow auth server AccessToken grant type is 'Password' which requires + UsernamePassword.""" + + @overload + def __init__( + self, + *, + auth_url: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + developer_token: Optional[str] = None, + password: Optional[str] = None, + refresh_token: Optional[str] = None, + tenant_id: Optional[str] = None, + username: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionPersonalAccessToken(_Model): + """ConnectionPersonalAccessToken. + + :ivar pat: + :vartype pat: str + """ + + pat: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + pat: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionPropertiesV2BasicResource(ProxyResource): + """Connection base resource schema. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Connection property base schema. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2 + """ + + properties: "_models.ConnectionPropertiesV2" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Connection property base schema. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.ConnectionPropertiesV2", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionServicePrincipal(_Model): + """ConnectionServicePrincipal. + + :ivar client_id: + :vartype client_id: str + :ivar client_secret: + :vartype client_secret: str + :ivar tenant_id: + :vartype tenant_id: str + """ + + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + tenant_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionSharedAccessSignature(_Model): + """ConnectionSharedAccessSignature. + + :ivar sas: + :vartype sas: str + """ + + sas: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + sas: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionUpdateContent(_Model): + """The properties that the Cognitive services connection will be updated with. + + :ivar properties: The properties that the Cognitive services connection will be updated with. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2 + """ + + properties: Optional["_models.ConnectionPropertiesV2"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties that the Cognitive services connection will be updated with.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ConnectionPropertiesV2"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectionUsernamePassword(_Model): + """ConnectionUsernamePassword. + + :ivar password: + :vartype password: str + :ivar security_token: Optional, required by connections like SalesForce for extra security in + addition to UsernamePassword. + :vartype security_token: str + :ivar username: + :vartype username: str + """ + + password: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + security_token: Optional[str] = rest_field( + name="securityToken", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional, required by connections like SalesForce for extra security in addition to + UsernamePassword.""" + username: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + password: Optional[str] = None, + security_token: Optional[str] = None, + username: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiBlocklistConfig(_Model): + """Azure OpenAI blocklist config. + + :ivar blocklist_name: Name of ContentFilter. + :vartype blocklist_name: str + :ivar blocking: If blocking would occur. + :vartype blocking: bool + """ + + blocklist_name: Optional[str] = rest_field( + name="blocklistName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of ContentFilter.""" + blocking: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If blocking would occur.""" + + @overload + def __init__( + self, + *, + blocklist_name: Optional[str] = None, + blocking: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomBlocklistConfig(RaiBlocklistConfig): + """Gets or sets the source to which filter applies. + + :ivar blocklist_name: Name of ContentFilter. + :vartype blocklist_name: str + :ivar blocking: If blocking would occur. + :vartype blocking: bool + :ivar source: Content source to apply the Content Filters. Known values are: "Prompt", + "Completion", "PreToolCall", "PostToolCall", "PreRun", and "PostRun". + :vartype source: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyContentSource + """ + + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Content source to apply the Content Filters. Known values are: \"Prompt\", \"Completion\", + \"PreToolCall\", \"PostToolCall\", \"PreRun\", and \"PostRun\".""" + + @overload + def __init__( + self, + *, + blocklist_name: Optional[str] = None, + blocking: Optional[bool] = None, + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomKeys(_Model): + """Custom Keys credential object. + + :ivar keys_property: Dictionary of . + :vartype keys_property: dict[str, str] + """ + + keys_property: Optional[dict[str, str]] = rest_field( + name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" + ) + """Dictionary of .""" + + @overload + def __init__( + self, + *, + keys_property: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomKeysConnectionProperties(ConnectionPropertiesV2, discriminator="CustomKeys"): + """Category:= CustomKeys AuthType:= CustomKeys (as type discriminator) Credentials:= {CustomKeys} + as CustomKeys Target:= {any value} Use Metadata property bag for ApiVersion and other metadata + fields. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: Custom Keys credential object. + :vartype credentials: ~azure.mgmt.cognitiveservices.models.CustomKeys + :ivar auth_type: Authentication type of the connection target. Required. CUSTOM_KEYS. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.CUSTOM_KEYS + """ + + credentials: Optional["_models.CustomKeys"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Custom Keys credential object.""" + auth_type: Literal[ConnectionAuthType.CUSTOM_KEYS] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. CUSTOM_KEYS.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.CustomKeys"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.CUSTOM_KEYS # type: ignore + + +class RaiTopicConfig(_Model): + """Azure OpenAI RAI topic config. + + :ivar topic_name: Name of RAI topic. + :vartype topic_name: str + :ivar blocking: If blocking would occur. + :vartype blocking: bool + """ + + topic_name: Optional[str] = rest_field(name="topicName", visibility=["read", "create", "update", "delete", "query"]) + """Name of RAI topic.""" + blocking: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If blocking would occur.""" + + @overload + def __init__( + self, + *, + topic_name: Optional[str] = None, + blocking: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomTopicConfig(RaiTopicConfig): + """Gets or sets the source to which filter applies. + + :ivar topic_name: Name of RAI topic. + :vartype topic_name: str + :ivar blocking: If blocking would occur. + :vartype blocking: bool + :ivar source: Content source to apply the Content Filters. Known values are: "Prompt", + "Completion", "PreToolCall", "PostToolCall", "PreRun", and "PostRun". + :vartype source: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyContentSource + """ + + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Content source to apply the Content Filters. Known values are: \"Prompt\", \"Completion\", + \"PreToolCall\", \"PostToolCall\", \"PreRun\", and \"PostRun\".""" + + @overload + def __init__( + self, + *, + topic_name: Optional[str] = None, + blocking: Optional[bool] = None, + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DefenderForAISetting(ProxyResource): + """The Defender for AI resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: The Defender for AI resource properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.DefenderForAISettingProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.DefenderForAISettingProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Defender for AI resource properties.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + __flattened_items = ["state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DefenderForAISettingProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DefenderForAISettingProperties(_Model): + """The Defender for AI resource properties. + + :ivar state: Defender for AI state on the AI resource. Known values are: "Disabled" and + "Enabled". + :vartype state: str or ~azure.mgmt.cognitiveservices.models.DefenderForAISettingState + """ + + state: Optional[Union[str, "_models.DefenderForAISettingState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defender for AI state on the AI resource. Known values are: \"Disabled\" and \"Enabled\".""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.DefenderForAISettingState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Deployment(ProxyResource): + """Cognitive Services account deployment. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services account deployment. + :vartype properties: ~azure.mgmt.cognitiveservices.models.DeploymentProperties + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.DeploymentProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services account deployment.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource model definition representing SKU.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.DeploymentProperties"] = None, + sku: Optional["_models.Sku"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeploymentCapacitySettings(_Model): + """Internal use only. + + :ivar designated_capacity: The designated capacity. + :vartype designated_capacity: int + :ivar priority: The priority of this capacity setting. + :vartype priority: int + """ + + designated_capacity: Optional[int] = rest_field( + name="designatedCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The designated capacity.""" + priority: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The priority of this capacity setting.""" + + @overload + def __init__( + self, + *, + designated_capacity: Optional[int] = None, + priority: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeploymentProperties(_Model): + """Properties of Cognitive Services account deployment. + + :ivar provisioning_state: Gets the status of the resource at the time the operation was called. + Known values are: "Accepted", "Creating", "Deleting", "Moving", "Failed", "Succeeded", + "Disabled", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.DeploymentProvisioningState + :ivar model: Properties of Cognitive Services account deployment model. + :vartype model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar scale_settings: Properties of Cognitive Services account deployment model. (Deprecated, + please use Deployment.sku instead.). + :vartype scale_settings: ~azure.mgmt.cognitiveservices.models.DeploymentScaleSettings + :ivar capabilities: The capabilities. + :vartype capabilities: dict[str, str] + :ivar rai_policy_name: The name of RAI policy. + :vartype rai_policy_name: str + :ivar call_rate_limit: The call rate limit Cognitive Services account. + :vartype call_rate_limit: ~azure.mgmt.cognitiveservices.models.CallRateLimit + :ivar rate_limits: + :vartype rate_limits: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + :ivar version_upgrade_option: Deployment model version upgrade option. Known values are: + "OnceNewDefaultVersionAvailable", "OnceCurrentVersionExpired", and "NoAutoUpgrade". + :vartype version_upgrade_option: str or + ~azure.mgmt.cognitiveservices.models.DeploymentModelVersionUpgradeOption + :ivar dynamic_throttling_enabled: If the dynamic throttling is enabled. + :vartype dynamic_throttling_enabled: bool + :ivar current_capacity: The current capacity. + :vartype current_capacity: int + :ivar capacity_settings: Internal use only. + :vartype capacity_settings: ~azure.mgmt.cognitiveservices.models.DeploymentCapacitySettings + :ivar parent_deployment_name: The name of parent deployment. + :vartype parent_deployment_name: str + :ivar spillover_deployment_name: Specifies the deployment name that should serve requests when + the request would have otherwise been throttled due to reaching current deployment throughput + limit. + :vartype spillover_deployment_name: str + :ivar service_tier: The service tier for the deployment. Determines the pricing and performance + level for request processing. Use 'Default' for standard pricing or 'Priority' for + higher-priority processing with premium pricing. Note: Pause operations are only supported on + Standard, DataZoneStandard, and GlobalStandard SKUs. Known values are: "Default" and + "Priority". + :vartype service_tier: str or ~azure.mgmt.cognitiveservices.models.ServiceTier + :ivar deployment_state: The state of the deployment. Controls whether the deployment is + accepting inference requests. Use 'Running' for active deployments that process requests, or + 'Paused' to temporarily stop inference while preserving the deployment configuration. Known + values are: "Running" and "Paused". + :vartype deployment_state: str or ~azure.mgmt.cognitiveservices.models.DeploymentState + """ + + provisioning_state: Optional[Union[str, "_models.DeploymentProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Gets the status of the resource at the time the operation was called. Known values are: + \"Accepted\", \"Creating\", \"Deleting\", \"Moving\", \"Failed\", \"Succeeded\", \"Disabled\", + and \"Canceled\".""" + model: Optional["_models.DeploymentModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Cognitive Services account deployment model.""" + scale_settings: Optional["_models.DeploymentScaleSettings"] = rest_field( + name="scaleSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services account deployment model. (Deprecated, please use + Deployment.sku instead.).""" + capabilities: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """The capabilities.""" + rai_policy_name: Optional[str] = rest_field( + name="raiPolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of RAI policy.""" + call_rate_limit: Optional["_models.CallRateLimit"] = rest_field(name="callRateLimit", visibility=["read"]) + """The call rate limit Cognitive Services account.""" + rate_limits: Optional[list["_models.ThrottlingRule"]] = rest_field(name="rateLimits", visibility=["read"]) + version_upgrade_option: Optional[Union[str, "_models.DeploymentModelVersionUpgradeOption"]] = rest_field( + name="versionUpgradeOption", visibility=["read", "create", "update", "delete", "query"] + ) + """Deployment model version upgrade option. Known values are: \"OnceNewDefaultVersionAvailable\", + \"OnceCurrentVersionExpired\", and \"NoAutoUpgrade\".""" + dynamic_throttling_enabled: Optional[bool] = rest_field(name="dynamicThrottlingEnabled", visibility=["read"]) + """If the dynamic throttling is enabled.""" + current_capacity: Optional[int] = rest_field( + name="currentCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The current capacity.""" + capacity_settings: Optional["_models.DeploymentCapacitySettings"] = rest_field( + name="capacitySettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Internal use only.""" + parent_deployment_name: Optional[str] = rest_field( + name="parentDeploymentName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of parent deployment.""" + spillover_deployment_name: Optional[str] = rest_field( + name="spilloverDeploymentName", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the deployment name that should serve requests when the request would have otherwise + been throttled due to reaching current deployment throughput limit.""" + service_tier: Optional[Union[str, "_models.ServiceTier"]] = rest_field( + name="serviceTier", visibility=["read", "create", "update", "delete", "query"] + ) + """The service tier for the deployment. Determines the pricing and performance level for request + processing. Use 'Default' for standard pricing or 'Priority' for higher-priority processing + with premium pricing. Note: Pause operations are only supported on Standard, DataZoneStandard, + and GlobalStandard SKUs. Known values are: \"Default\" and \"Priority\".""" + deployment_state: Optional[Union[str, "_models.DeploymentState"]] = rest_field( + name="deploymentState", visibility=["read", "create", "update", "delete", "query"] + ) + """The state of the deployment. Controls whether the deployment is accepting inference requests. + Use 'Running' for active deployments that process requests, or 'Paused' to temporarily stop + inference while preserving the deployment configuration. Known values are: \"Running\" and + \"Paused\".""" + + @overload + def __init__( + self, + *, + model: Optional["_models.DeploymentModel"] = None, + scale_settings: Optional["_models.DeploymentScaleSettings"] = None, + rai_policy_name: Optional[str] = None, + version_upgrade_option: Optional[Union[str, "_models.DeploymentModelVersionUpgradeOption"]] = None, + current_capacity: Optional[int] = None, + capacity_settings: Optional["_models.DeploymentCapacitySettings"] = None, + parent_deployment_name: Optional[str] = None, + spillover_deployment_name: Optional[str] = None, + service_tier: Optional[Union[str, "_models.ServiceTier"]] = None, + deployment_state: Optional[Union[str, "_models.DeploymentState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeploymentScaleSettings(_Model): + """Properties of Cognitive Services account deployment model. (Deprecated, please use + Deployment.sku instead.). + + :ivar scale_type: Deployment scale type. Known values are: "Standard" and "Manual". + :vartype scale_type: str or ~azure.mgmt.cognitiveservices.models.DeploymentScaleType + :ivar capacity: Deployment capacity. + :vartype capacity: int + :ivar active_capacity: Deployment active capacity. This value might be different from + ``capacity`` if customer recently updated ``capacity``. + :vartype active_capacity: int + """ + + scale_type: Optional[Union[str, "_models.DeploymentScaleType"]] = rest_field( + name="scaleType", visibility=["read", "create", "update", "delete", "query"] + ) + """Deployment scale type. Known values are: \"Standard\" and \"Manual\".""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Deployment capacity.""" + active_capacity: Optional[int] = rest_field(name="activeCapacity", visibility=["read"]) + """Deployment active capacity. This value might be different from ``capacity`` if customer + recently updated ``capacity``.""" + + @overload + def __init__( + self, + *, + scale_type: Optional[Union[str, "_models.DeploymentScaleType"]] = None, + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DomainAvailability(_Model): + """Domain availability. + + :ivar is_subdomain_available: Indicates the given SKU is available or not. + :vartype is_subdomain_available: bool + :ivar reason: Reason why the SKU is not available. + :vartype reason: str + :ivar subdomain_name: The subdomain name to use. + :vartype subdomain_name: str + :ivar type: The Type of the resource. + :vartype type: str + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + """ + + is_subdomain_available: Optional[bool] = rest_field( + name="isSubdomainAvailable", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates the given SKU is available or not.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Reason why the SKU is not available.""" + subdomain_name: Optional[str] = rest_field( + name="subdomainName", visibility=["read", "create", "update", "delete", "query"] + ) + """The subdomain name to use.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Type of the resource.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + + @overload + def __init__( + self, + *, + is_subdomain_available: Optional[bool] = None, + reason: Optional[str] = None, + subdomain_name: Optional[str] = None, + type: Optional[str] = None, + kind: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Encryption(_Model): + """Properties to configure Encryption. + + :ivar key_vault_properties: Properties of KeyVault. + :vartype key_vault_properties: ~azure.mgmt.cognitiveservices.models.KeyVaultProperties + :ivar key_source: Enumerates the possible value of keySource for Encryption. Known values are: + "Microsoft.CognitiveServices" and "Microsoft.KeyVault". + :vartype key_source: str or ~azure.mgmt.cognitiveservices.models.KeySource + """ + + key_vault_properties: Optional["_models.KeyVaultProperties"] = rest_field( + name="keyVaultProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of KeyVault.""" + key_source: Optional[Union[str, "_models.KeySource"]] = rest_field( + name="keySource", visibility=["read", "create", "update", "delete", "query"] + ) + """Enumerates the possible value of keySource for Encryption. Known values are: + \"Microsoft.CognitiveServices\" and \"Microsoft.KeyVault\".""" + + @overload + def __init__( + self, + *, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + key_source: Optional[Union[str, "_models.KeySource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EncryptionScope(ProxyResource): + """Cognitive Services EncryptionScope. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services EncryptionScope. + :vartype properties: ~azure.mgmt.cognitiveservices.models.EncryptionScopeProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.EncryptionScopeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services EncryptionScope.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.EncryptionScopeProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EncryptionScopeProperties(Encryption): + """Properties to EncryptionScope. + + :ivar key_vault_properties: Properties of KeyVault. + :vartype key_vault_properties: ~azure.mgmt.cognitiveservices.models.KeyVaultProperties + :ivar key_source: Enumerates the possible value of keySource for Encryption. Known values are: + "Microsoft.CognitiveServices" and "Microsoft.KeyVault". + :vartype key_source: str or ~azure.mgmt.cognitiveservices.models.KeySource + :ivar provisioning_state: Gets the status of the resource at the time the operation was called. + Known values are: "Accepted", "Creating", "Deleting", "Moving", "Failed", "Succeeded", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.EncryptionScopeProvisioningState + :ivar state: The encryptionScope state. Known values are: "Disabled" and "Enabled". + :vartype state: str or ~azure.mgmt.cognitiveservices.models.EncryptionScopeState + """ + + provisioning_state: Optional[Union[str, "_models.EncryptionScopeProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Gets the status of the resource at the time the operation was called. Known values are: + \"Accepted\", \"Creating\", \"Deleting\", \"Moving\", \"Failed\", \"Succeeded\", and + \"Canceled\".""" + state: Optional[Union[str, "_models.EncryptionScopeState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The encryptionScope state. Known values are: \"Disabled\" and \"Enabled\".""" + + @overload + def __init__( + self, + *, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + key_source: Optional[Union[str, "_models.KeySource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.cognitiveservices.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.cognitiveservices.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.cognitiveservices.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OutboundRule(_Model): + """Outbound Rule for the managed network of a cognitive services account. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + FqdnOutboundRule + + :ivar category: Category of a managed network Outbound Rule of a cognitive services account. + Known values are: "Required", "Recommended", "UserDefined", and "Dependency". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.RuleCategory + :ivar status: Type of a managed network Outbound Rule of a cognitive services account. Known + values are: "Inactive", "Active", "Provisioning", "Deleting", and "Failed". + :vartype status: str or ~azure.mgmt.cognitiveservices.models.RuleStatus + :ivar type: Type of a managed network Outbound Rule of a cognitive services account. Required. + Known values are: "FQDN", "PrivateEndpoint", and "ServiceTag". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.RuleType + :ivar error_information: Error information about an outbound rule of a cognitive services + account if RuleStatus is failed. + :vartype error_information: str + :ivar parent_rule_names: + :vartype parent_rule_names: list[str] + """ + + __mapping__: dict[str, _Model] = {} + category: Optional[Union[str, "_models.RuleCategory"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Category of a managed network Outbound Rule of a cognitive services account. Known values are: + \"Required\", \"Recommended\", \"UserDefined\", and \"Dependency\".""" + status: Optional[Union[str, "_models.RuleStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of a managed network Outbound Rule of a cognitive services account. Known values are: + \"Inactive\", \"Active\", \"Provisioning\", \"Deleting\", and \"Failed\".""" + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Type of a managed network Outbound Rule of a cognitive services account. Required. Known values + are: \"FQDN\", \"PrivateEndpoint\", and \"ServiceTag\".""" + error_information: Optional[str] = rest_field(name="errorInformation", visibility=["read"]) + """Error information about an outbound rule of a cognitive services account if RuleStatus is + failed.""" + parent_rule_names: Optional[list[str]] = rest_field(name="parentRuleNames", visibility=["read"]) + + @overload + def __init__( + self, + *, + type: str, + category: Optional[Union[str, "_models.RuleCategory"]] = None, + status: Optional[Union[str, "_models.RuleStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FqdnOutboundRule(OutboundRule, discriminator="FQDN"): + """FQDN Outbound Rule for the managed network of a cognitive services account. + + :ivar category: Category of a managed network Outbound Rule of a cognitive services account. + Known values are: "Required", "Recommended", "UserDefined", and "Dependency". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.RuleCategory + :ivar status: Type of a managed network Outbound Rule of a cognitive services account. Known + values are: "Inactive", "Active", "Provisioning", "Deleting", and "Failed". + :vartype status: str or ~azure.mgmt.cognitiveservices.models.RuleStatus + :ivar error_information: Error information about an outbound rule of a cognitive services + account if RuleStatus is failed. + :vartype error_information: str + :ivar parent_rule_names: + :vartype parent_rule_names: list[str] + :ivar destination: + :vartype destination: str + :ivar type: Type of a managed network Outbound Rule of a cognitive services account. Required. + FQDN. + :vartype type: str or ~azure.mgmt.cognitiveservices.models.FQDN + """ + + destination: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Literal[RuleType.FQDN] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Type of a managed network Outbound Rule of a cognitive services account. Required. FQDN.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.RuleCategory"]] = None, + status: Optional[Union[str, "_models.RuleStatus"]] = None, + destination: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = RuleType.FQDN # type: ignore + + +class HostedAgentDeployment(AgentDeploymentProperties, discriminator="Hosted"): + """Represents a hosted agent deployment where the underlying infrastructure is owned by the + platform. + + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar display_name: Gets or sets the display name of the deployment. + :vartype display_name: str + :ivar deployment_id: Gets or sets the unique identifier of the deployment. + :vartype deployment_id: str + :ivar state: Gets or sets the current operational state of the deployment (and, intrinsically, + of the comprising agents). Known values are: "Starting", "Running", "Stopping", "Stopped", + "Failed", "Deleting", "Deleted", and "Updating". + :vartype state: str or ~azure.mgmt.cognitiveservices.models.AgentDeploymentState + :ivar protocols: Gets or sets the supported protocol types and versions exposed by this + deployment. + :vartype protocols: list[~azure.mgmt.cognitiveservices.models.AgentProtocolVersion] + :ivar agents: Returns a flat list of agent:version deployed in this deployment. + :vartype agents: list[~azure.mgmt.cognitiveservices.models.VersionedAgentReference] + :ivar provisioning_state: Gets or sets the provisioning state of the agent deployment. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.AgentDeploymentProvisioningState + :ivar min_replicas: Gets or sets the minimum number of replicas for this hosted deployment. + :vartype min_replicas: int + :ivar max_replicas: Gets or sets the maximum number of replicas for this hosted deployment. + :vartype max_replicas: int + :ivar deployment_type: Gets or sets the type of deployment for the agent. Required. The + underlying infra is owned by the platform. + :vartype deployment_type: str or ~azure.mgmt.cognitiveservices.models.HOSTED + """ + + min_replicas: Optional[int] = rest_field( + name="minReplicas", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the minimum number of replicas for this hosted deployment.""" + max_replicas: Optional[int] = rest_field( + name="maxReplicas", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the maximum number of replicas for this hosted deployment.""" + deployment_type: Literal[AgentDeploymentType.HOSTED] = rest_discriminator(name="deploymentType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Gets or sets the type of deployment for the agent. Required. The underlying infra is owned by + the platform.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + display_name: Optional[str] = None, + deployment_id: Optional[str] = None, + state: Optional[Union[str, "_models.AgentDeploymentState"]] = None, + protocols: Optional[list["_models.AgentProtocolVersion"]] = None, + agents: Optional[list["_models.VersionedAgentReference"]] = None, + min_replicas: Optional[int] = None, + max_replicas: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.deployment_type = AgentDeploymentType.HOSTED # type: ignore + + +class Identity(_Model): + """Identity for the resource. + + :ivar type: The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned, UserAssigned". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.ResourceIdentityType + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar user_assigned_identities: The list of user assigned identities associated with the + resource. The user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.cognitiveservices.models.UserAssignedIdentity] + """ + + type: Optional[Union[str, "_models.ResourceIdentityType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The identity type. Known values are: \"None\", \"SystemAssigned\", \"UserAssigned\", and + \"SystemAssigned, UserAssigned\".""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of resource.""" + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of resource identity.""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of user assigned identities associated with the resource. The user identity dictionary + key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IpRule(_Model): + """A rule governing the accessibility from a specific ip address or ip range. + + :ivar value: An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) + or '124.56.78.0/24' (all addresses that start with 124.56.78). Required. + :vartype value: str + """ + + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An IPv4 address range in CIDR notation, such as '124.56.78.91' (simple IP address) or + '124.56.78.0/24' (all addresses that start with 124.56.78). Required.""" + + @overload + def __init__( + self, + *, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyVaultProperties(_Model): + """Properties to configure keyVault Properties. + + :ivar key_name: Name of the Key from KeyVault. + :vartype key_name: str + :ivar key_version: Version of the Key from KeyVault. + :vartype key_version: str + :ivar key_vault_uri: Uri of KeyVault. + :vartype key_vault_uri: str + :ivar identity_client_id: + :vartype identity_client_id: str + """ + + key_name: Optional[str] = rest_field(name="keyName", visibility=["read", "create", "update", "delete", "query"]) + """Name of the Key from KeyVault.""" + key_version: Optional[str] = rest_field( + name="keyVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Version of the Key from KeyVault.""" + key_vault_uri: Optional[str] = rest_field( + name="keyVaultUri", visibility=["read", "create", "update", "delete", "query"] + ) + """Uri of KeyVault.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + key_vault_uri: Optional[str] = None, + identity_client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedAgentDeployment(AgentDeploymentProperties, discriminator="Managed"): + """Represents a managed agent deployment where the underlying infrastructure is managed by the + platform in the deployer's subscription. + + :ivar description: The asset description text. + :vartype description: str + :ivar tags: Tag dictionary. Tags can be added, removed, and updated. + :vartype tags: dict[str, str] + :ivar display_name: Gets or sets the display name of the deployment. + :vartype display_name: str + :ivar deployment_id: Gets or sets the unique identifier of the deployment. + :vartype deployment_id: str + :ivar state: Gets or sets the current operational state of the deployment (and, intrinsically, + of the comprising agents). Known values are: "Starting", "Running", "Stopping", "Stopped", + "Failed", "Deleting", "Deleted", and "Updating". + :vartype state: str or ~azure.mgmt.cognitiveservices.models.AgentDeploymentState + :ivar protocols: Gets or sets the supported protocol types and versions exposed by this + deployment. + :vartype protocols: list[~azure.mgmt.cognitiveservices.models.AgentProtocolVersion] + :ivar agents: Returns a flat list of agent:version deployed in this deployment. + :vartype agents: list[~azure.mgmt.cognitiveservices.models.VersionedAgentReference] + :ivar provisioning_state: Gets or sets the provisioning state of the agent deployment. Known + values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.AgentDeploymentProvisioningState + :ivar deployment_type: Gets or sets the type of deployment for the agent. Required. The + underlying infra is managed by the platform in the deployer's subscription. + :vartype deployment_type: str or ~azure.mgmt.cognitiveservices.models.MANAGED + """ + + deployment_type: Literal[AgentDeploymentType.MANAGED] = rest_discriminator(name="deploymentType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Gets or sets the type of deployment for the agent. Required. The underlying infra is managed by + the platform in the deployer's subscription.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + tags: Optional[dict[str, str]] = None, + display_name: Optional[str] = None, + deployment_id: Optional[str] = None, + state: Optional[Union[str, "_models.AgentDeploymentState"]] = None, + protocols: Optional[list["_models.AgentProtocolVersion"]] = None, + agents: Optional[list["_models.VersionedAgentReference"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.deployment_type = AgentDeploymentType.MANAGED # type: ignore + + +class ManagedIdentityAuthTypeConnectionProperties( + ConnectionPropertiesV2, discriminator="ManagedIdentity" +): # pylint: disable=name-too-long + """ManagedIdentityAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionManagedIdentity + :ivar auth_type: Authentication type of the connection target. Required. MANAGED_IDENTITY. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.MANAGED_IDENTITY + """ + + credentials: Optional["_models.ConnectionManagedIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auth_type: Literal[ConnectionAuthType.MANAGED_IDENTITY] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. MANAGED_IDENTITY.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionManagedIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.MANAGED_IDENTITY # type: ignore + + +class ManagedNetworkProvisionOptions(_Model): + """Managed Network Provisioning options for managed network of a cognitive services account.""" + + +class ManagedNetworkProvisionStatus(_Model): + """Status of the Provisioning for the managed network of a cognitive services account. + + :ivar status: Status for the managed network of a cognitive services account. Known values are: + "Inactive" and "Active". + :vartype status: str or ~azure.mgmt.cognitiveservices.models.ManagedNetworkStatus + """ + + status: Optional[Union[str, "_models.ManagedNetworkStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Status for the managed network of a cognitive services account. Known values are: \"Inactive\" + and \"Active\".""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.ManagedNetworkStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedNetworkSettings(_Model): + """Managed Network settings for a cognitive services account. + + :ivar isolation_mode: Isolation mode for the managed network of a cognitive services account. + Known values are: "Disabled", "AllowInternetOutbound", and "AllowOnlyApprovedOutbound". + :vartype isolation_mode: str or ~azure.mgmt.cognitiveservices.models.IsolationMode + :ivar network_id: + :vartype network_id: str + :ivar outbound_rules: Dictionary of . + :vartype outbound_rules: dict[str, ~azure.mgmt.cognitiveservices.models.OutboundRule] + :ivar status: Status of the Provisioning for the managed network of a cognitive services + account. + :vartype status: ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus + :ivar firewall_sku: Firewall Sku used for FQDN Rules. Known values are: "Standard" and "Basic". + :vartype firewall_sku: str or ~azure.mgmt.cognitiveservices.models.FirewallSku + :ivar managed_network_kind: The Kind of the managed network. Users can switch from V1 to V2 for + granular access controls, but cannot switch back to V1 once V2 is enabled. Known values are: + "V1" and "V2". + :vartype managed_network_kind: str or ~azure.mgmt.cognitiveservices.models.ManagedNetworkKind + :ivar egress_ip_address: Public IP address assigned to the Azure Firewall. + :vartype egress_ip_address: str + """ + + isolation_mode: Optional[Union[str, "_models.IsolationMode"]] = rest_field( + name="isolationMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Isolation mode for the managed network of a cognitive services account. Known values are: + \"Disabled\", \"AllowInternetOutbound\", and \"AllowOnlyApprovedOutbound\".""" + network_id: Optional[str] = rest_field(name="networkId", visibility=["read"]) + outbound_rules: Optional[dict[str, "_models.OutboundRule"]] = rest_field( + name="outboundRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Dictionary of .""" + status: Optional["_models.ManagedNetworkProvisionStatus"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Status of the Provisioning for the managed network of a cognitive services account.""" + firewall_sku: Optional[Union[str, "_models.FirewallSku"]] = rest_field( + name="firewallSku", visibility=["read", "create", "update", "delete", "query"] + ) + """Firewall Sku used for FQDN Rules. Known values are: \"Standard\" and \"Basic\".""" + managed_network_kind: Optional[Union[str, "_models.ManagedNetworkKind"]] = rest_field( + name="managedNetworkKind", visibility=["read", "create", "update", "delete", "query"] + ) + """The Kind of the managed network. Users can switch from V1 to V2 for granular access controls, + but cannot switch back to V1 once V2 is enabled. Known values are: \"V1\" and \"V2\".""" + egress_ip_address: Optional[str] = rest_field(name="egressIpAddress", visibility=["read"]) + """Public IP address assigned to the Azure Firewall.""" + + @overload + def __init__( + self, + *, + isolation_mode: Optional[Union[str, "_models.IsolationMode"]] = None, + outbound_rules: Optional[dict[str, "_models.OutboundRule"]] = None, + status: Optional["_models.ManagedNetworkProvisionStatus"] = None, + firewall_sku: Optional[Union[str, "_models.FirewallSku"]] = None, + managed_network_kind: Optional[Union[str, "_models.ManagedNetworkKind"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedNetworkSettingsBasicResource(Resource): + """ManagedNetworkSettingsBasicResource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Managed Network settings for a cognitive services account. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettings + """ + + properties: Optional["_models.ManagedNetworkSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed Network settings for a cognitive services account.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedNetworkSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedNetworkSettingsEx(ManagedNetworkSettings): + """ManagedNetworkSettingsEx. + + :ivar isolation_mode: Isolation mode for the managed network of a cognitive services account. + Known values are: "Disabled", "AllowInternetOutbound", and "AllowOnlyApprovedOutbound". + :vartype isolation_mode: str or ~azure.mgmt.cognitiveservices.models.IsolationMode + :ivar network_id: + :vartype network_id: str + :ivar outbound_rules: Dictionary of . + :vartype outbound_rules: dict[str, ~azure.mgmt.cognitiveservices.models.OutboundRule] + :ivar status: Status of the Provisioning for the managed network of a cognitive services + account. + :vartype status: ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus + :ivar firewall_sku: Firewall Sku used for FQDN Rules. Known values are: "Standard" and "Basic". + :vartype firewall_sku: str or ~azure.mgmt.cognitiveservices.models.FirewallSku + :ivar managed_network_kind: The Kind of the managed network. Users can switch from V1 to V2 for + granular access controls, but cannot switch back to V1 once V2 is enabled. Known values are: + "V1" and "V2". + :vartype managed_network_kind: str or ~azure.mgmt.cognitiveservices.models.ManagedNetworkKind + :ivar egress_ip_address: Public IP address assigned to the Azure Firewall. + :vartype egress_ip_address: str + :ivar changeable_isolation_modes: + :vartype changeable_isolation_modes: list[str or + ~azure.mgmt.cognitiveservices.models.IsolationMode] + """ + + changeable_isolation_modes: Optional[list[Union[str, "_models.IsolationMode"]]] = rest_field( + name="changeableIsolationModes", visibility=["read"] + ) + + @overload + def __init__( + self, + *, + isolation_mode: Optional[Union[str, "_models.IsolationMode"]] = None, + outbound_rules: Optional[dict[str, "_models.OutboundRule"]] = None, + status: Optional["_models.ManagedNetworkProvisionStatus"] = None, + firewall_sku: Optional[Union[str, "_models.FirewallSku"]] = None, + managed_network_kind: Optional[Union[str, "_models.ManagedNetworkKind"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedNetworkSettingsProperties(_Model): + """The properties of the managed network settings of a cognitive services account. + + :ivar managed_network: Managed Network settings for a cognitive services account. + :vartype managed_network: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsEx + :ivar provisioning_state: The current deployment state of the managed network resource. The + provisioningState is to indicate states for resource provisioning. Known values are: + "Deferred", "Updating", "Succeeded", "Failed", "Deleting", and "Deleted". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisioningState + """ + + managed_network: Optional["_models.ManagedNetworkSettingsEx"] = rest_field( + name="managedNetwork", visibility=["read", "create", "update", "delete", "query"] + ) + """Managed Network settings for a cognitive services account.""" + provisioning_state: Optional[Union[str, "_models.ManagedNetworkProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The current deployment state of the managed network resource. The provisioningState is to + indicate states for resource provisioning. Known values are: \"Deferred\", \"Updating\", + \"Succeeded\", \"Failed\", \"Deleting\", and \"Deleted\".""" + + @overload + def __init__( + self, + *, + managed_network: Optional["_models.ManagedNetworkSettingsEx"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedNetworkSettingsPropertiesBasicResource(ProxyResource): # pylint: disable=name-too-long + """Concrete proxy resource types can be created by aliasing this type using a specific property + type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: The properties of the managed network settings of a cognitive services + account. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsProperties + """ + + properties: Optional["_models.ManagedNetworkSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the managed network settings of a cognitive services account.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedNetworkSettingsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricName(_Model): + """A metric name. + + :ivar value: The name of the metric. + :vartype value: str + :ivar localized_value: The friendly name of the metric. + :vartype localized_value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the metric.""" + localized_value: Optional[str] = rest_field( + name="localizedValue", visibility=["read", "create", "update", "delete", "query"] + ) + """The friendly name of the metric.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Model(_Model): + """Cognitive Services Model. + + :ivar model: Cognitive Services account Model. + :vartype model: ~azure.mgmt.cognitiveservices.models.AccountModel + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + :ivar sku_name: The name of SKU. + :vartype sku_name: str + :ivar description: The description of the model. + :vartype description: str + """ + + model: Optional["_models.AccountModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cognitive Services account Model.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + sku_name: Optional[str] = rest_field(name="skuName", visibility=["read", "create", "update", "delete", "query"]) + """The name of SKU.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the model.""" + + @overload + def __init__( + self, + *, + model: Optional["_models.AccountModel"] = None, + kind: Optional[str] = None, + sku_name: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ModelCapacityCalculatorWorkload(_Model): + """Model Capacity Calculator Workload. + + :ivar request_per_minute: Request per minute. + :vartype request_per_minute: int + :ivar request_parameters: Dictionary, Model Capacity Calculator Workload Parameters. + :vartype request_parameters: + ~azure.mgmt.cognitiveservices.models.ModelCapacityCalculatorWorkloadRequestParam + """ + + request_per_minute: Optional[int] = rest_field( + name="requestPerMinute", visibility=["read", "create", "update", "delete", "query"] + ) + """Request per minute.""" + request_parameters: Optional["_models.ModelCapacityCalculatorWorkloadRequestParam"] = rest_field( + name="requestParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Dictionary, Model Capacity Calculator Workload Parameters.""" + + @overload + def __init__( + self, + *, + request_per_minute: Optional[int] = None, + request_parameters: Optional["_models.ModelCapacityCalculatorWorkloadRequestParam"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ModelCapacityCalculatorWorkloadRequestParam(_Model): # pylint: disable=name-too-long + """Dictionary, Model Capacity Calculator Workload Parameters. + + :ivar avg_prompt_tokens: Average prompt tokens. + :vartype avg_prompt_tokens: int + :ivar avg_generated_tokens: Average generated tokens. + :vartype avg_generated_tokens: int + """ + + avg_prompt_tokens: Optional[int] = rest_field( + name="avgPromptTokens", visibility=["read", "create", "update", "delete", "query"] + ) + """Average prompt tokens.""" + avg_generated_tokens: Optional[int] = rest_field( + name="avgGeneratedTokens", visibility=["read", "create", "update", "delete", "query"] + ) + """Average generated tokens.""" + + @overload + def __init__( + self, + *, + avg_prompt_tokens: Optional[int] = None, + avg_generated_tokens: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ModelCapacityListResultValueItem(ProxyResource): + """ModelCapacityListResultValueItem. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar location: The location of the Model Sku Capacity. + :vartype location: str + :ivar properties: Cognitive Services account ModelSkuCapacity. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ModelSkuCapacityProperties + """ + + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The location of the Model Sku Capacity.""" + properties: Optional["_models.ModelSkuCapacityProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Cognitive Services account ModelSkuCapacity.""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["_models.ModelSkuCapacityProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ModelDeprecationInfo(_Model): + """Cognitive Services account ModelDeprecationInfo. + + :ivar fine_tune: The datetime of deprecation of the fineTune Model. + :vartype fine_tune: str + :ivar inference: The datetime of deprecation of the inference Model. + :vartype inference: str + :ivar deprecation_status: Indicates whether the deprecation date is a confirmed planned + end-of-life date or an estimated deprecation date. When 'Planned', the deprecation date + represents a confirmed and communicated model end-of-life date. When 'Tentative', the + deprecation date is an estimated timeline that may be subject to change. Known values are: + "Planned" and "Tentative". + :vartype deprecation_status: str or ~azure.mgmt.cognitiveservices.models.DeprecationStatus + """ + + fine_tune: Optional[str] = rest_field(name="fineTune", visibility=["read", "create", "update", "delete", "query"]) + """The datetime of deprecation of the fineTune Model.""" + inference: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The datetime of deprecation of the inference Model.""" + deprecation_status: Optional[Union[str, "_models.DeprecationStatus"]] = rest_field( + name="deprecationStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the deprecation date is a confirmed planned end-of-life date or an estimated + deprecation date. When 'Planned', the deprecation date represents a confirmed and communicated + model end-of-life date. When 'Tentative', the deprecation date is an estimated timeline that + may be subject to change. Known values are: \"Planned\" and \"Tentative\".""" + + @overload + def __init__( + self, + *, + fine_tune: Optional[str] = None, + inference: Optional[str] = None, + deprecation_status: Optional[Union[str, "_models.DeprecationStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ModelSku(_Model): + """Describes an available Cognitive Services Model SKU. + + :ivar name: The name of the model SKU. + :vartype name: str + :ivar usage_name: The usage name of the model SKU. + :vartype usage_name: str + :ivar deprecation_date: The datetime of deprecation of the model SKU. + :vartype deprecation_date: ~datetime.datetime + :ivar capacity: The capacity configuration. + :vartype capacity: ~azure.mgmt.cognitiveservices.models.CapacityConfig + :ivar rate_limits: The list of rateLimit. + :vartype rate_limits: list[~azure.mgmt.cognitiveservices.models.CallRateLimit] + :ivar cost: The list of billing meter info. + :vartype cost: list[~azure.mgmt.cognitiveservices.models.BillingMeterInfo] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the model SKU.""" + usage_name: Optional[str] = rest_field(name="usageName", visibility=["read", "create", "update", "delete", "query"]) + """The usage name of the model SKU.""" + deprecation_date: Optional[datetime.datetime] = rest_field( + name="deprecationDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The datetime of deprecation of the model SKU.""" + capacity: Optional["_models.CapacityConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The capacity configuration.""" + rate_limits: Optional[list["_models.CallRateLimit"]] = rest_field( + name="rateLimits", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of rateLimit.""" + cost: Optional[list["_models.BillingMeterInfo"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of billing meter info.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + usage_name: Optional[str] = None, + deprecation_date: Optional[datetime.datetime] = None, + capacity: Optional["_models.CapacityConfig"] = None, + rate_limits: Optional[list["_models.CallRateLimit"]] = None, + cost: Optional[list["_models.BillingMeterInfo"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ModelSkuCapacityProperties(_Model): + """Cognitive Services account ModelSkuCapacity. + + :ivar model: Properties of Cognitive Services account deployment model. + :vartype model: ~azure.mgmt.cognitiveservices.models.DeploymentModel + :ivar sku_name: + :vartype sku_name: str + :ivar available_capacity: The available capacity for deployment with this model and sku. + :vartype available_capacity: float + :ivar available_finetune_capacity: The available capacity for deployment with a fine-tune + version of this model and sku. + :vartype available_finetune_capacity: float + """ + + model: Optional["_models.DeploymentModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of Cognitive Services account deployment model.""" + sku_name: Optional[str] = rest_field(name="skuName", visibility=["read", "create", "update", "delete", "query"]) + available_capacity: Optional[float] = rest_field( + name="availableCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The available capacity for deployment with this model and sku.""" + available_finetune_capacity: Optional[float] = rest_field( + name="availableFinetuneCapacity", visibility=["read", "create", "update", "delete", "query"] + ) + """The available capacity for deployment with a fine-tune version of this model and sku.""" + + @overload + def __init__( + self, + *, + model: Optional["_models.DeploymentModel"] = None, + sku_name: Optional[str] = None, + available_capacity: Optional[float] = None, + available_finetune_capacity: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MultiRegionSettings(_Model): + """The multiregion settings Cognitive Services account. + + :ivar routing_method: Multiregion routing methods. Known values are: "Priority", "Weighted", + and "Performance". + :vartype routing_method: str or ~azure.mgmt.cognitiveservices.models.RoutingMethods + :ivar regions: + :vartype regions: list[~azure.mgmt.cognitiveservices.models.RegionSetting] + """ + + routing_method: Optional[Union[str, "_models.RoutingMethods"]] = rest_field( + name="routingMethod", visibility=["read", "create", "update", "delete", "query"] + ) + """Multiregion routing methods. Known values are: \"Priority\", \"Weighted\", and \"Performance\".""" + regions: Optional[list["_models.RegionSetting"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + routing_method: Optional[Union[str, "_models.RoutingMethods"]] = None, + regions: Optional[list["_models.RegionSetting"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkInjection(_Model): + """Specifies in AI Foundry where virtual network injection occurs to secure scenarios like Agents + entirely within the user's private network, eliminating public internet exposure while + maintaining control over network configurations and resources. + + :ivar scenario: Specifies what features in AI Foundry network injection applies to. Currently + only supports 'agent' for agent scenarios. 'none' means no network injection. Known values are: + "none" and "agent". + :vartype scenario: str or ~azure.mgmt.cognitiveservices.models.ScenarioType + :ivar subnet_arm_id: Specify the subnet for which your Agent Client is injected into. + :vartype subnet_arm_id: str + :ivar use_microsoft_managed_network: Boolean to enable Microsoft Managed Network for subnet + delegation. + :vartype use_microsoft_managed_network: bool + """ + + scenario: Optional[Union[str, "_models.ScenarioType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies what features in AI Foundry network injection applies to. Currently only supports + 'agent' for agent scenarios. 'none' means no network injection. Known values are: \"none\" and + \"agent\".""" + subnet_arm_id: Optional[str] = rest_field( + name="subnetArmId", visibility=["read", "create", "update", "delete", "query"] + ) + """Specify the subnet for which your Agent Client is injected into.""" + use_microsoft_managed_network: Optional[bool] = rest_field( + name="useMicrosoftManagedNetwork", visibility=["read", "create", "update", "delete", "query"] + ) + """Boolean to enable Microsoft Managed Network for subnet delegation.""" + + @overload + def __init__( + self, + *, + scenario: Optional[Union[str, "_models.ScenarioType"]] = None, + subnet_arm_id: Optional[str] = None, + use_microsoft_managed_network: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkRuleSet(_Model): + """A set of rules governing the network accessibility. + + :ivar default_action: The default action when no rule from ipRules and from virtualNetworkRules + match. This is only used after the bypass property has been evaluated. Known values are: + "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.cognitiveservices.models.NetworkRuleAction + :ivar bypass: Setting for trusted services. Known values are: "None" and "AzureServices". + :vartype bypass: str or ~azure.mgmt.cognitiveservices.models.ByPassSelection + :ivar ip_rules: The list of IP address rules. + :vartype ip_rules: list[~azure.mgmt.cognitiveservices.models.IpRule] + :ivar virtual_network_rules: The list of virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.cognitiveservices.models.VirtualNetworkRule] + """ + + default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = rest_field( + name="defaultAction", visibility=["read", "create", "update", "delete", "query"] + ) + """The default action when no rule from ipRules and from virtualNetworkRules match. This is only + used after the bypass property has been evaluated. Known values are: \"Allow\" and \"Deny\".""" + bypass: Optional[Union[str, "_models.ByPassSelection"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Setting for trusted services. Known values are: \"None\" and \"AzureServices\".""" + ip_rules: Optional[list["_models.IpRule"]] = rest_field( + name="ipRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of IP address rules.""" + virtual_network_rules: Optional[list["_models.VirtualNetworkRule"]] = rest_field( + name="virtualNetworkRules", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of virtual network rules.""" + + @overload + def __init__( + self, + *, + default_action: Optional[Union[str, "_models.NetworkRuleAction"]] = None, + bypass: Optional[Union[str, "_models.ByPassSelection"]] = None, + ip_rules: Optional[list["_models.IpRule"]] = None, + virtual_network_rules: Optional[list["_models.VirtualNetworkRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeter(_Model): + """Information about a linked Network Security Perimeter. + + :ivar id: Fully qualified identifier of the resource. + :vartype id: str + :ivar perimeter_guid: Guid of the resource. + :vartype perimeter_guid: str + :ivar location: Location of the resource. + :vartype location: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified identifier of the resource.""" + perimeter_guid: Optional[str] = rest_field( + name="perimeterGuid", visibility=["read", "create", "update", "delete", "query"] + ) + """Guid of the resource.""" + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Location of the resource.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterAccessRule(_Model): + """Network Security Perimeter Access Rule. + + :ivar name: Network Security Perimeter Access Rule Name. + :vartype name: str + :ivar properties: Properties of Network Security Perimeter Access Rule. + :vartype properties: + ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRuleProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Network Security Perimeter Access Rule Name.""" + properties: Optional["_models.NetworkSecurityPerimeterAccessRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Network Security Perimeter Access Rule.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NetworkSecurityPerimeterAccessRuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterAccessRuleProperties(_Model): # pylint: disable=name-too-long + """The Properties of Network Security Perimeter Rule. + + :ivar direction: Direction of Access Rule. Known values are: "Inbound" and "Outbound". + :vartype direction: str or ~azure.mgmt.cognitiveservices.models.NspAccessRuleDirection + :ivar address_prefixes: Address prefixes for inbound rules. + :vartype address_prefixes: list[str] + :ivar subscriptions: Subscriptions for inbound rules. + :vartype subscriptions: + list[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem] + :ivar network_security_perimeters: NetworkSecurityPerimeters for inbound rules. + :vartype network_security_perimeters: + list[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeter] + :ivar fully_qualified_domain_names: Fully qualified domain name for outbound rules. + :vartype fully_qualified_domain_names: list[str] + """ + + direction: Optional[Union[str, "_models.NspAccessRuleDirection"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Direction of Access Rule. Known values are: \"Inbound\" and \"Outbound\".""" + address_prefixes: Optional[list[str]] = rest_field( + name="addressPrefixes", visibility=["read", "create", "update", "delete", "query"] + ) + """Address prefixes for inbound rules.""" + subscriptions: Optional[list["_models.NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscriptions for inbound rules.""" + network_security_perimeters: Optional[list["_models.NetworkSecurityPerimeter"]] = rest_field( + name="networkSecurityPerimeters", visibility=["read", "create", "update", "delete", "query"] + ) + """NetworkSecurityPerimeters for inbound rules.""" + fully_qualified_domain_names: Optional[list[str]] = rest_field( + name="fullyQualifiedDomainNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Fully qualified domain name for outbound rules.""" + + @overload + def __init__( + self, + *, + direction: Optional[Union[str, "_models.NspAccessRuleDirection"]] = None, + address_prefixes: Optional[list[str]] = None, + subscriptions: Optional[list["_models.NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem"]] = None, + network_security_perimeters: Optional[list["_models.NetworkSecurityPerimeter"]] = None, + fully_qualified_domain_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterAccessRulePropertiesSubscriptionsItem(_Model): # pylint: disable=name-too-long + """Subscription for inbound rule. + + :ivar id: Fully qualified identifier of subscription. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified identifier of subscription.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterConfiguration(ProxyResource): + """NSP Configuration for an Cognitive Services account. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: NSP Configuration properties. + :vartype properties: + ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationProperties + """ + + properties: Optional["_models.NetworkSecurityPerimeterConfigurationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """NSP Configuration properties.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.NetworkSecurityPerimeterConfigurationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterConfigurationAssociationInfo(_Model): # pylint: disable=name-too-long + """Network Security Perimeter Configuration Association Information. + + :ivar name: Name of the resource association. + :vartype name: str + :ivar access_mode: Access Mode of the resource association. + :vartype access_mode: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the resource association.""" + access_mode: Optional[str] = rest_field( + name="accessMode", visibility=["read", "create", "update", "delete", "query"] + ) + """Access Mode of the resource association.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + access_mode: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterConfigurationProperties(_Model): # pylint: disable=name-too-long + """The properties of an NSP Configuration. + + :ivar provisioning_state: Provisioning state of NetworkSecurityPerimeter configuration. + :vartype provisioning_state: str + :ivar provisioning_issues: List of Provisioning Issues. + :vartype provisioning_issues: list[~azure.mgmt.cognitiveservices.models.ProvisioningIssue] + :ivar network_security_perimeter: Information about a linked Network Security Perimeter. + :vartype network_security_perimeter: + ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeter + :ivar resource_association: Network Security Perimeter Configuration Association Information. + :vartype resource_association: + ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfigurationAssociationInfo + :ivar profile: Network Security Perimeter Profile Information. + :vartype profile: ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterProfileInfo + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """Provisioning state of NetworkSecurityPerimeter configuration.""" + provisioning_issues: Optional[list["_models.ProvisioningIssue"]] = rest_field( + name="provisioningIssues", visibility=["read", "create", "update", "delete", "query"] + ) + """List of Provisioning Issues.""" + network_security_perimeter: Optional["_models.NetworkSecurityPerimeter"] = rest_field( + name="networkSecurityPerimeter", visibility=["read", "create", "update", "delete", "query"] + ) + """Information about a linked Network Security Perimeter.""" + resource_association: Optional["_models.NetworkSecurityPerimeterConfigurationAssociationInfo"] = rest_field( + name="resourceAssociation", visibility=["read", "create", "update", "delete", "query"] + ) + """Network Security Perimeter Configuration Association Information.""" + profile: Optional["_models.NetworkSecurityPerimeterProfileInfo"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Network Security Perimeter Profile Information.""" + + @overload + def __init__( + self, + *, + provisioning_issues: Optional[list["_models.ProvisioningIssue"]] = None, + network_security_perimeter: Optional["_models.NetworkSecurityPerimeter"] = None, + resource_association: Optional["_models.NetworkSecurityPerimeterConfigurationAssociationInfo"] = None, + profile: Optional["_models.NetworkSecurityPerimeterProfileInfo"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkSecurityPerimeterProfileInfo(_Model): + """Network Security Perimeter Profile Information. + + :ivar name: Name of the resource profile. + :vartype name: str + :ivar access_rules_version: Access rules version of the resource profile. + :vartype access_rules_version: int + :ivar access_rules: + :vartype access_rules: + list[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRule] + :ivar diagnostic_settings_version: Current diagnostic settings version. + :vartype diagnostic_settings_version: int + :ivar enabled_log_categories: List of enabled log categories. + :vartype enabled_log_categories: list[str] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the resource profile.""" + access_rules_version: Optional[int] = rest_field( + name="accessRulesVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Access rules version of the resource profile.""" + access_rules: Optional[list["_models.NetworkSecurityPerimeterAccessRule"]] = rest_field( + name="accessRules", visibility=["read", "create", "update", "delete", "query"] + ) + diagnostic_settings_version: Optional[int] = rest_field( + name="diagnosticSettingsVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Current diagnostic settings version.""" + enabled_log_categories: Optional[list[str]] = rest_field( + name="enabledLogCategories", visibility=["read", "create", "update", "delete", "query"] + ) + """List of enabled log categories.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + access_rules_version: Optional[int] = None, + access_rules: Optional[list["_models.NetworkSecurityPerimeterAccessRule"]] = None, + diagnostic_settings_version: Optional[int] = None, + enabled_log_categories: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NoneAuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="None"): + """NoneAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar auth_type: Authentication type of the connection target. Required. NONE. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.NONE + """ + + auth_type: Literal[ConnectionAuthType.NONE] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. NONE.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.NONE # type: ignore + + +class OAuth2AuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="OAuth2"): + """OAuth2AuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: ClientId and ClientSecret are required. Other properties are optional + depending on each OAuth2 provider's implementation. + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionOAuth2 + :ivar auth_type: Authentication type of the connection target. Required. O_AUTH2. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.O_AUTH2 + """ + + credentials: Optional["_models.ConnectionOAuth2"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """ClientId and ClientSecret are required. Other properties are optional depending on each OAuth2 + provider's implementation.""" + auth_type: Literal[ConnectionAuthType.O_AUTH2] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. O_AUTH2.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionOAuth2"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.O_AUTH2 # type: ignore + + +class Operation(_Model): + """REST API Operation. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for Azure Resource Manager/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.cognitiveservices.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.cognitiveservices.models.Origin + :ivar action_type: Extensible enum. Indicates the action type. "Internal" refers to actions + that are for internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.cognitiveservices.models.ActionType + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + \"Microsoft.Compute/virtualMachines/write\", + \"Microsoft.Compute/virtualMachines/capture/action\".""" + is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) + """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and + \"false\" for Azure Resource Manager/control-plane operations.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Localized display information for this particular operation.""" + origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and + \"user,system\".""" + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) + """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for + internal only APIs. \"Internal\"""" + + @overload + def __init__( + self, + *, + display: Optional["_models.OperationDisplay"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """Localized display information for an operation. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring + Insights\" or \"Microsoft Compute\".""" + resource: Optional[str] = rest_field(visibility=["read"]) + """The localized friendly name of the resource type related to this operation. E.g. \"Virtual + Machines\" or \"Job Schedule Collections\".""" + operation: Optional[str] = rest_field(visibility=["read"]) + """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create + or Update Virtual Machine\", \"Restart Virtual Machine\".""" + description: Optional[str] = rest_field(visibility=["read"]) + """The short, localized friendly description of the operation; suitable for tool tips and detailed + views.""" + + +class OrganizationSharedBuiltInAuthorizationPolicy( + ApplicationAuthorizationPolicy, discriminator="OrganizationScope" +): # pylint: disable=name-too-long + """Built-in authorization policy scoped to organization/tenant. + + :ivar type: Authorization scheme type. Required. Claim-based, requires membership in the + tenant. + :vartype type: str or ~azure.mgmt.cognitiveservices.models.ORGANIZATION_SCOPE + """ + + type: Literal[BuiltInAuthorizationScheme.ORGANIZATION_SCOPE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authorization scheme type. Required. Claim-based, requires membership in the tenant.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = BuiltInAuthorizationScheme.ORGANIZATION_SCOPE # type: ignore + + +class OutboundRuleBasicResource(ProxyResource): + """Concrete proxy resource types can be created by aliasing this type using a specific property + type. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Outbound Rule for the managed network of a cognitive services account. + Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.OutboundRule + """ + + properties: "_models.OutboundRule" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Outbound Rule for the managed network of a cognitive services account. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.OutboundRule", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OutboundRuleListResult(_Model): + """List of outbound rules for the managed network of a cognitive services account. + + :ivar next_link: The link to the next page constructed using the continuationToken. If null, + there are no additional pages. + :vartype next_link: str + :ivar value: The list of cognitive services accounts. Since this list may be incomplete, the + nextLink field should be used to request the next list of cognitive services accounts. + :vartype value: list[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + """ + + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link to the next page constructed using the continuationToken. If null, there are no + additional pages.""" + value: Optional[list["_models.OutboundRuleBasicResource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of cognitive services accounts. Since this list may be incomplete, the nextLink field + should be used to request the next list of cognitive services accounts.""" + + @overload + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[list["_models.OutboundRuleBasicResource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PATAuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="PAT"): + """PATAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionPersonalAccessToken + :ivar auth_type: Authentication type of the connection target. Required. PAT. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.PAT + """ + + credentials: Optional["_models.ConnectionPersonalAccessToken"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auth_type: Literal[ConnectionAuthType.PAT] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. PAT.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionPersonalAccessToken"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.PAT # type: ignore + + +class PatchResourceTags(_Model): + """The object being used to update tags of a resource, in general used for PATCH operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PatchResourceTagsAndSku(PatchResourceTags): + """The object being used to update tags and sku of a resource, in general used for PATCH + operations. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + """ + + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource model definition representing SKU.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Pool(_Model): + """Compute pool configuration. + + :ivar name: Pool name identifier. Required. + :vartype name: str + :ivar vm_priority: Priority of VM instances in this pool. Known values are: "Regular" and + "Spot". + :vartype vm_priority: str or ~azure.mgmt.cognitiveservices.models.VmPriority + :ivar instance_type: VM size for this pool. Required. + :vartype instance_type: str + :ivar node_count: Number of nodes in this pool. Required. + :vartype node_count: int + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Pool name identifier. Required.""" + vm_priority: Optional[Union[str, "_models.VmPriority"]] = rest_field( + name="vmPriority", visibility=["read", "create", "update", "delete", "query"] + ) + """Priority of VM instances in this pool. Known values are: \"Regular\" and \"Spot\".""" + instance_type: str = rest_field(name="instanceType", visibility=["read", "create", "update", "delete", "query"]) + """VM size for this pool. Required.""" + node_count: int = rest_field(name="nodeCount", visibility=["read", "create", "update", "delete", "query"]) + """Number of nodes in this pool. Required.""" + + @overload + def __init__( + self, + *, + name: str, + instance_type: str, + node_count: int, + vm_priority: Optional[Union[str, "_models.VmPriority"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpoint(_Model): + """The private endpoint resource. + + :ivar id: The resource identifier of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The resource identifier of the private endpoint.""" + + +class PrivateEndpointConnection(ProxyResource): + """The Private Endpoint Connection resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar location: The location of the private endpoint connection. + :vartype location: str + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The location of the private endpoint connection.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnectionListResult(_Model): + """A list of private endpoint connections. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + """ + + value: Optional[list["_models.PrivateEndpointConnection"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Array of private endpoint connections.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.PrivateEndpointConnection"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnectionProperties(_Model): + """Properties of the PrivateEndpointConnectProperties. + + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.cognitiveservices.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.cognitiveservices.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionProvisioningState + :ivar group_ids: The private link resource group ids. + :vartype group_ids: list[str] + """ + + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource of private end point.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider. Required.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of the private endpoint connection resource. Known values are: + \"Succeeded\", \"Creating\", \"Deleting\", and \"Failed\".""" + group_ids: Optional[list[str]] = rest_field( + name="groupIds", visibility=["read", "create", "update", "delete", "query"] + ) + """The private link resource group ids.""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + group_ids: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(Resource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResourceListResult(_Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.cognitiveservices.models.PrivateLinkResource] + """ + + value: Optional[list["_models.PrivateLinkResource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Array of private link resources.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.PrivateLinkResource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + :ivar display_name: The private link resource display name. + :vartype display_name: str + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The private link resource Private link DNS zone name.""" + display_name: Optional[str] = rest_field(name="displayName", visibility=["read"]) + """The private link resource display name.""" + + @overload + def __init__( + self, + *, + required_zone_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkServiceConnectionState(_Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.cognitiveservices.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Project(Resource): + """Cognitive Services project is an Azure resource representing the provisioned account's project, + it's type, location and SKU. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services project. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ProjectProperties + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.cognitiveservices.models.Identity + """ + + properties: Optional["_models.ProjectProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services project.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + location: Optional[str] = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + identity: Optional["_models.Identity"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identity for the resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProjectProperties"] = None, + tags: Optional[dict[str, str]] = None, + location: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProjectCapabilityHost(ProxyResource): + """Azure Resource Manager resource envelope for Project CapabilityHost. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: [Required] Additional attributes of the entity. Required. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHostProperties + """ + + properties: "_models.ProjectCapabilityHostProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """[Required] Additional attributes of the entity. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.ProjectCapabilityHostProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProjectCapabilityHostProperties(_Model): + """ProjectCapabilityHostProperties. + + :ivar ai_services_connections: List of AI services connections. + :vartype ai_services_connections: list[str] + :ivar vector_store_connections: List of connection names from those available in the account or + project to be used for vector database (e.g. CosmosDB). + :vartype vector_store_connections: list[str] + :ivar storage_connections: List of connection names from those available in the account or + project to be used as a storage resource. + :vartype storage_connections: list[str] + :ivar thread_storage_connections: List of connection names from those available in the account + or project to be used for Thread storage. + :vartype thread_storage_connections: list[str] + :ivar provisioning_state: Provisioning state for the CapabilityHost. Known values are: + "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.cognitiveservices.models.CapabilityHostProvisioningState + """ + + ai_services_connections: Optional[list[str]] = rest_field( + name="aiServicesConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of AI services connections.""" + vector_store_connections: Optional[list[str]] = rest_field( + name="vectorStoreConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of connection names from those available in the account or project to be used for vector + database (e.g. CosmosDB).""" + storage_connections: Optional[list[str]] = rest_field( + name="storageConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of connection names from those available in the account or project to be used as a storage + resource.""" + thread_storage_connections: Optional[list[str]] = rest_field( + name="threadStorageConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of connection names from those available in the account or project to be used for Thread + storage.""" + provisioning_state: Optional[Union[str, "_models.CapabilityHostProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state for the CapabilityHost. Known values are: \"Succeeded\", \"Failed\", + \"Canceled\", \"Creating\", \"Updating\", and \"Deleting\".""" + + @overload + def __init__( + self, + *, + ai_services_connections: Optional[list[str]] = None, + vector_store_connections: Optional[list[str]] = None, + storage_connections: Optional[list[str]] = None, + thread_storage_connections: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProjectProperties(_Model): + """Properties of Cognitive Services Project'. + + :ivar provisioning_state: Gets the status of the cognitive services project at the time the + operation was called. Known values are: "Accepted", "Creating", "Deleting", "Moving", "Failed", + "Succeeded", "Canceled", and "ResolvingDNS". + :vartype provisioning_state: str or ~azure.mgmt.cognitiveservices.models.ProvisioningState + :ivar display_name: The display name of the Cognitive Services Project. + :vartype display_name: str + :ivar description: The description of the Cognitive Services Project. + :vartype description: str + :ivar endpoints: The list of endpoint for this Cognitive Services Project. + :vartype endpoints: dict[str, str] + :ivar is_default: Indicates whether the project is the default project for the account. + :vartype is_default: bool + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Gets the status of the cognitive services project at the time the operation was called. Known + values are: \"Accepted\", \"Creating\", \"Deleting\", \"Moving\", \"Failed\", \"Succeeded\", + \"Canceled\", and \"ResolvingDNS\".""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The display name of the Cognitive Services Project.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description of the Cognitive Services Project.""" + endpoints: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """The list of endpoint for this Cognitive Services Project.""" + is_default: Optional[bool] = rest_field(name="isDefault", visibility=["read"]) + """Indicates whether the project is the default project for the account.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProvisioningIssue(_Model): + """ProvisioningIssue. + + :ivar name: Name of the NSP provisioning issue. + :vartype name: str + :ivar properties: Properties of Provisioning Issue. + :vartype properties: ~azure.mgmt.cognitiveservices.models.ProvisioningIssueProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the NSP provisioning issue.""" + properties: Optional["_models.ProvisioningIssueProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Provisioning Issue.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.ProvisioningIssueProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProvisioningIssueProperties(_Model): + """Properties of Provisioning Issue. + + :ivar issue_type: Type of Issue. + :vartype issue_type: str + :ivar severity: Severity of the issue. + :vartype severity: str + :ivar description: Description of the issue. + :vartype description: str + :ivar suggested_resource_ids: IDs of resources that can be associated to the same perimeter to + remediate the issue. + :vartype suggested_resource_ids: list[str] + :ivar suggested_access_rules: Optional array, suggested access rules. + :vartype suggested_access_rules: + list[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterAccessRule] + """ + + issue_type: Optional[str] = rest_field(name="issueType", visibility=["read", "create", "update", "delete", "query"]) + """Type of Issue.""" + severity: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Severity of the issue.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the issue.""" + suggested_resource_ids: Optional[list[str]] = rest_field( + name="suggestedResourceIds", visibility=["read", "create", "update", "delete", "query"] + ) + """IDs of resources that can be associated to the same perimeter to remediate the issue.""" + suggested_access_rules: Optional[list["_models.NetworkSecurityPerimeterAccessRule"]] = rest_field( + name="suggestedAccessRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional array, suggested access rules.""" + + @overload + def __init__( + self, + *, + issue_type: Optional[str] = None, + severity: Optional[str] = None, + description: Optional[str] = None, + suggested_resource_ids: Optional[list[str]] = None, + suggested_access_rules: Optional[list["_models.NetworkSecurityPerimeterAccessRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaLimit(_Model): + """QuotaLimit. + + :ivar count: + :vartype count: float + :ivar renewal_period: + :vartype renewal_period: float + :ivar rules: + :vartype rules: list[~azure.mgmt.cognitiveservices.models.ThrottlingRule] + """ + + count: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + renewal_period: Optional[float] = rest_field( + name="renewalPeriod", visibility=["read", "create", "update", "delete", "query"] + ) + rules: Optional[list["_models.ThrottlingRule"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + count: Optional[float] = None, + renewal_period: Optional[float] = None, + rules: Optional[list["_models.ThrottlingRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaTier(ProxyResource): + """The quota tier information for the subscription. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of quota tier resource. + :vartype properties: ~azure.mgmt.cognitiveservices.models.QuotaTierProperties + """ + + properties: Optional["_models.QuotaTierProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of quota tier resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.QuotaTierProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaTierProperties(_Model): + """Properties of Quota Tier resource'. + + :ivar current_tier_name: Name of the current quota tier for the subscription. + :vartype current_tier_name: str + :ivar tier_upgrade_policy: Gets the tier upgrade policy for the subscription. Known values are: + "OnceUpgradeIsAvailable" and "NoAutoUpgrade". + :vartype tier_upgrade_policy: str or ~azure.mgmt.cognitiveservices.models.TierUpgradePolicy + :ivar assignment_date: The date on which the current tier was assigned to the subscription + (UTC). + :vartype assignment_date: ~datetime.datetime + :ivar tier_upgrade_eligibility_info: Information about the quota tier upgrade eligibility for + the subscription. + :vartype tier_upgrade_eligibility_info: + ~azure.mgmt.cognitiveservices.models.QuotaTierUpgradeEligibilityInfo + """ + + current_tier_name: Optional[str] = rest_field(name="currentTierName", visibility=["read"]) + """Name of the current quota tier for the subscription.""" + tier_upgrade_policy: Optional[Union[str, "_models.TierUpgradePolicy"]] = rest_field( + name="tierUpgradePolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the tier upgrade policy for the subscription. Known values are: \"OnceUpgradeIsAvailable\" + and \"NoAutoUpgrade\".""" + assignment_date: Optional[datetime.datetime] = rest_field( + name="assignmentDate", visibility=["read"], format="rfc3339" + ) + """The date on which the current tier was assigned to the subscription (UTC).""" + tier_upgrade_eligibility_info: Optional["_models.QuotaTierUpgradeEligibilityInfo"] = rest_field( + name="tierUpgradeEligibilityInfo", visibility=["read"] + ) + """Information about the quota tier upgrade eligibility for the subscription.""" + + @overload + def __init__( + self, + *, + tier_upgrade_policy: Optional[Union[str, "_models.TierUpgradePolicy"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaTierUpgradeEligibilityInfo(_Model): + """Information about the quota tier upgrade eligibility for the subscription. + + :ivar next_tier_name: Name of the next quota tier for the subscription. + :vartype next_tier_name: str + :ivar upgrade_availability_status: Specifies whether an upgrade to the next quota tier is + available. Known values are: "Available" and "NotAvailable". + :vartype upgrade_availability_status: str or + ~azure.mgmt.cognitiveservices.models.UpgradeAvailabilityStatus + :ivar upgrade_applicable_date: The date after which the current tier will be upgraded to the + next tier if the TierUpgradePolicy is "OnceUpgradeIsAvailable" (UTC). + :vartype upgrade_applicable_date: ~datetime.datetime + :ivar upgrade_unavailability_reason: Reason in case the subscription is not eligible for + upgrade to the next tier. + :vartype upgrade_unavailability_reason: str + """ + + next_tier_name: Optional[str] = rest_field( + name="nextTierName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the next quota tier for the subscription.""" + upgrade_availability_status: Optional[Union[str, "_models.UpgradeAvailabilityStatus"]] = rest_field( + name="upgradeAvailabilityStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether an upgrade to the next quota tier is available. Known values are: + \"Available\" and \"NotAvailable\".""" + upgrade_applicable_date: Optional[datetime.datetime] = rest_field( + name="upgradeApplicableDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date after which the current tier will be upgraded to the next tier if the + TierUpgradePolicy is \"OnceUpgradeIsAvailable\" (UTC).""" + upgrade_unavailability_reason: Optional[str] = rest_field( + name="upgradeUnavailabilityReason", visibility=["read", "create", "update", "delete", "query"] + ) + """Reason in case the subscription is not eligible for upgrade to the next tier.""" + + @overload + def __init__( + self, + *, + next_tier_name: Optional[str] = None, + upgrade_availability_status: Optional[Union[str, "_models.UpgradeAvailabilityStatus"]] = None, + upgrade_applicable_date: Optional[datetime.datetime] = None, + upgrade_unavailability_reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiBlocklist(ProxyResource): + """Cognitive Services RaiBlocklist. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services RaiBlocklist. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiBlocklistProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.RaiBlocklistProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services RaiBlocklist.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiBlocklistProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiBlocklistItem(ProxyResource): + """Cognitive Services RaiBlocklist Item. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services RaiBlocklist Item. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItemProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.RaiBlocklistItemProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services RaiBlocklist Item.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiBlocklistItemProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiBlocklistItemBulkRequest(_Model): + """The Cognitive Services RaiBlocklist Item request body. + + :ivar name: + :vartype name: str + :ivar properties: Properties of Cognitive Services RaiBlocklist Item. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItemProperties + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + properties: Optional["_models.RaiBlocklistItemProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services RaiBlocklist Item.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.RaiBlocklistItemProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiBlocklistItemProperties(_Model): + """RAI Custom Blocklist Item properties. + + :ivar pattern: Pattern to match against. + :vartype pattern: str + :ivar is_regex: If the pattern is a regex pattern. + :vartype is_regex: bool + """ + + pattern: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Pattern to match against.""" + is_regex: Optional[bool] = rest_field(name="isRegex", visibility=["read", "create", "update", "delete", "query"]) + """If the pattern is a regex pattern.""" + + @overload + def __init__( + self, + *, + pattern: Optional[str] = None, + is_regex: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiBlocklistProperties(_Model): + """RAI Custom Blocklist properties. + + :ivar description: Description of the block list. + :vartype description: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the block list.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiContentFilter(ProxyResource): + """Azure OpenAI Content Filter. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Azure OpenAI Content Filter Properties. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiContentFilterProperties + """ + + properties: Optional["_models.RaiContentFilterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Azure OpenAI Content Filter Properties.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiContentFilterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiContentFilterProperties(_Model): + """Azure OpenAI Content Filter Properties. + + :ivar name: Name of Content Filter. + :vartype name: str + :ivar is_multi_level_filter: If the Content Filter has multi severity levels(Low, Medium, or + High). + :vartype is_multi_level_filter: bool + :ivar source: Content source to apply the Content Filters. Known values are: "Prompt", + "Completion", "PreToolCall", "PostToolCall", "PreRun", and "PostRun". + :vartype source: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyContentSource + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of Content Filter.""" + is_multi_level_filter: Optional[bool] = rest_field( + name="isMultiLevelFilter", visibility=["read", "create", "update", "delete", "query"] + ) + """If the Content Filter has multi severity levels(Low, Medium, or High).""" + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Content source to apply the Content Filters. Known values are: \"Prompt\", \"Completion\", + \"PreToolCall\", \"PostToolCall\", \"PreRun\", and \"PostRun\".""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + is_multi_level_filter: Optional[bool] = None, + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiExternalSafetyProvider(ProxyResource): + """Cognitive Services Rai External Safety provider. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar properties: Properties of Cognitive Services Rai External Safety provider. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderProperties + """ + + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Resource tags.""" + properties: Optional["_models.RaiExternalSafetyProviderProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services Rai External Safety provider.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiExternalSafetyProviderProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiExternalSafetyProviderProperties(_Model): + """RAI External SafetyProvider properties. + + :ivar provider_id: The unique identifier of the safety provider. + :vartype provider_id: str + :ivar provider_name: Name of the safety provider. + :vartype provider_name: str + :ivar mode: Safety provider mode sync/async. + :vartype mode: str + :ivar url: Webhook URL for the safety provider. + :vartype url: str + :ivar created_at: Creation time of the safety provider. + :vartype created_at: ~datetime.datetime + :ivar last_modified_at: Last modified time of the safety provider. + :vartype last_modified_at: ~datetime.datetime + """ + + provider_id: Optional[str] = rest_field( + name="providerId", visibility=["read", "create", "update", "delete", "query"] + ) + """The unique identifier of the safety provider.""" + provider_name: Optional[str] = rest_field( + name="providerName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the safety provider.""" + mode: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Safety provider mode sync/async.""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Webhook URL for the safety provider.""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Creation time of the safety provider.""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last modified time of the safety provider.""" + + @overload + def __init__( + self, + *, + provider_id: Optional[str] = None, + provider_name: Optional[str] = None, + mode: Optional[str] = None, + url: Optional[str] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiExternalSafetyProviderSchema(ProxyResource): + """Cognitive Services Rai External Safety provider Schema. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services Rai External Safety provider. + :vartype properties: + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchemaProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.RaiExternalSafetyProviderSchemaProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services Rai External Safety provider.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiExternalSafetyProviderSchemaProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiExternalSafetyProviderSchemaProperties(_Model): # pylint: disable=name-too-long + """RAI External SafetyProvider schema properties. + + :ivar provider_id: The unique identifier of the safety provider. + :vartype provider_id: str + :ivar provider_name: Name of the safety provider. + :vartype provider_name: str + :ivar mode: Safety provider mode sync/async. + :vartype mode: str + :ivar url: Webhook URL for the safety provider. + :vartype url: str + :ivar secret_name: The name of the secret in Key Vault that contains the api key to access the + webhook. + :vartype secret_name: str + :ivar managed_identity: The managed identity to access the Key Vault. + :vartype managed_identity: str + :ivar key_vault_uri: The Key Vault URI that contains the api key for safety provider urls. + :vartype key_vault_uri: str + :ivar created_at: Creation time of the safety provider. + :vartype created_at: ~datetime.datetime + :ivar last_modified_at: Last modified time of the safety provider. + :vartype last_modified_at: ~datetime.datetime + """ + + provider_id: Optional[str] = rest_field( + name="providerId", visibility=["read", "create", "update", "delete", "query"] + ) + """The unique identifier of the safety provider.""" + provider_name: Optional[str] = rest_field( + name="providerName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the safety provider.""" + mode: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Safety provider mode sync/async.""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Webhook URL for the safety provider.""" + secret_name: Optional[str] = rest_field( + name="secretName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the secret in Key Vault that contains the api key to access the webhook.""" + managed_identity: Optional[str] = rest_field( + name="managedIdentity", visibility=["read", "create", "update", "delete", "query"] + ) + """The managed identity to access the Key Vault.""" + key_vault_uri: Optional[str] = rest_field( + name="keyVaultUri", visibility=["read", "create", "update", "delete", "query"] + ) + """The Key Vault URI that contains the api key for safety provider urls.""" + created_at: Optional[datetime.datetime] = rest_field(name="createdAt", visibility=["read"], format="rfc3339") + """Creation time of the safety provider.""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read"], format="rfc3339" + ) + """Last modified time of the safety provider.""" + + @overload + def __init__( + self, + *, + provider_id: Optional[str] = None, + provider_name: Optional[str] = None, + mode: Optional[str] = None, + url: Optional[str] = None, + secret_name: Optional[str] = None, + managed_identity: Optional[str] = None, + key_vault_uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiMonitorConfig(_Model): + """Cognitive Services Rai Monitor Config. + + :ivar adx_storage_resource_id: The storage resource Id. + :vartype adx_storage_resource_id: str + :ivar identity_client_id: The identity client Id to access the storage. + :vartype identity_client_id: str + """ + + adx_storage_resource_id: Optional[str] = rest_field( + name="adxStorageResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The storage resource Id.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity client Id to access the storage.""" + + @overload + def __init__( + self, + *, + adx_storage_resource_id: Optional[str] = None, + identity_client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiPolicy(ProxyResource): + """Cognitive Services RaiPolicy. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services RaiPolicy. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiPolicyProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.RaiPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services RaiPolicy.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiPolicyProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiPolicyContentFilter(_Model): + """Azure OpenAI Content Filter. + + :ivar name: Name of ContentFilter. + :vartype name: str + :ivar enabled: If the ContentFilter is enabled. + :vartype enabled: bool + :ivar severity_threshold: Level at which content is filtered. Known values are: "Low", + "Medium", and "High". + :vartype severity_threshold: str or ~azure.mgmt.cognitiveservices.models.ContentLevel + :ivar blocking: If blocking would occur. + :vartype blocking: bool + :ivar source: Content source to apply the Content Filters. Known values are: "Prompt", + "Completion", "PreToolCall", "PostToolCall", "PreRun", and "PostRun". + :vartype source: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyContentSource + :ivar action: The action types to apply to the content filters. Known values are: "None", + "BLOCKING", "ANNOTATING", "HITL", and "RETRY". + :vartype action: str or ~azure.mgmt.cognitiveservices.models.RaiActionType + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of ContentFilter.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If the ContentFilter is enabled.""" + severity_threshold: Optional[Union[str, "_models.ContentLevel"]] = rest_field( + name="severityThreshold", visibility=["read", "create", "update", "delete", "query"] + ) + """Level at which content is filtered. Known values are: \"Low\", \"Medium\", and \"High\".""" + blocking: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If blocking would occur.""" + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Content source to apply the Content Filters. Known values are: \"Prompt\", \"Completion\", + \"PreToolCall\", \"PostToolCall\", \"PreRun\", and \"PostRun\".""" + action: Optional[Union[str, "_models.RaiActionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The action types to apply to the content filters. Known values are: \"None\", \"BLOCKING\", + \"ANNOTATING\", \"HITL\", and \"RETRY\".""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + enabled: Optional[bool] = None, + severity_threshold: Optional[Union[str, "_models.ContentLevel"]] = None, + blocking: Optional[bool] = None, + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = None, + action: Optional[Union[str, "_models.RaiActionType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiPolicyProperties(_Model): + """Azure OpenAI Content Filters properties. + + :ivar type: Content Filters policy type. Known values are: "UserManaged" and "SystemManaged". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyType + :ivar mode: Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, + Blocking=2, Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2025-06-01. It is + the same as 'Deferred' in previous version. Known values are: "Default", "Deferred", + "Blocking", and "Asynchronous_filter". + :vartype mode: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyMode + :ivar base_policy_name: Name of Rai policy. + :vartype base_policy_name: str + :ivar content_filters: The list of Content Filters. + :vartype content_filters: list[~azure.mgmt.cognitiveservices.models.RaiPolicyContentFilter] + :ivar custom_blocklists: The list of custom Blocklist. + :vartype custom_blocklists: list[~azure.mgmt.cognitiveservices.models.CustomBlocklistConfig] + :ivar custom_topics: The list of custom rai topics. + :vartype custom_topics: list[~azure.mgmt.cognitiveservices.models.CustomTopicConfig] + :ivar safety_providers: The list of Safety Providers. + :vartype safety_providers: list[~azure.mgmt.cognitiveservices.models.SafetyProviderConfig] + """ + + type: Optional[Union[str, "_models.RaiPolicyType"]] = rest_field(visibility=["read"]) + """Content Filters policy type. Known values are: \"UserManaged\" and \"SystemManaged\".""" + mode: Optional[Union[str, "_models.RaiPolicyMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Rai policy mode. The enum value mapping is as below: Default = 0, Deferred=1, Blocking=2, + Asynchronous_filter =3. Please use 'Asynchronous_filter' after 2025-06-01. It is the same as + 'Deferred' in previous version. Known values are: \"Default\", \"Deferred\", \"Blocking\", and + \"Asynchronous_filter\".""" + base_policy_name: Optional[str] = rest_field( + name="basePolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of Rai policy.""" + content_filters: Optional[list["_models.RaiPolicyContentFilter"]] = rest_field( + name="contentFilters", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of Content Filters.""" + custom_blocklists: Optional[list["_models.CustomBlocklistConfig"]] = rest_field( + name="customBlocklists", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of custom Blocklist.""" + custom_topics: Optional[list["_models.CustomTopicConfig"]] = rest_field( + name="customTopics", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of custom rai topics.""" + safety_providers: Optional[list["_models.SafetyProviderConfig"]] = rest_field( + name="safetyProviders", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of Safety Providers.""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.RaiPolicyMode"]] = None, + base_policy_name: Optional[str] = None, + content_filters: Optional[list["_models.RaiPolicyContentFilter"]] = None, + custom_blocklists: Optional[list["_models.CustomBlocklistConfig"]] = None, + custom_topics: Optional[list["_models.CustomTopicConfig"]] = None, + safety_providers: Optional[list["_models.SafetyProviderConfig"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiSafetyProviderConfig(_Model): + """Azure OpenAI RAI safety provider config. + + :ivar safety_provider_name: Name of RAI Safety Provider. + :vartype safety_provider_name: str + :ivar blocking: If blocking would occur. + :vartype blocking: bool + """ + + safety_provider_name: Optional[str] = rest_field( + name="safetyProviderName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of RAI Safety Provider.""" + blocking: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If blocking would occur.""" + + @overload + def __init__( + self, + *, + safety_provider_name: Optional[str] = None, + blocking: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiToolLabel(ProxyResource): + """Cognitive Services RAI Tool Label resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of the RAI Tool Label. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiToolLabelProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.RaiToolLabelProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the RAI Tool Label.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiToolLabelProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiToolLabelProperties(_Model): + """RAI Tool Label properties. + + :ivar tool_connection_name: The unique tool connection name, e.g., 'Web_Search'. Required. + :vartype tool_connection_name: str + :ivar account_scope: Account-level tool label definition. + :vartype account_scope: ~azure.mgmt.cognitiveservices.models.RaiToolLabelPropertiesAccountScope + :ivar project_scopes: List of project-level tool label definitions. + :vartype project_scopes: + list[~azure.mgmt.cognitiveservices.models.RaiToolLabelPropertiesProjectScopesItem] + """ + + tool_connection_name: str = rest_field( + name="toolConnectionName", visibility=["read", "create", "update", "delete", "query"] + ) + """The unique tool connection name, e.g., 'Web_Search'. Required.""" + account_scope: Optional["_models.RaiToolLabelPropertiesAccountScope"] = rest_field( + name="accountScope", visibility=["read", "create", "update", "delete", "query"] + ) + """Account-level tool label definition.""" + project_scopes: Optional[list["_models.RaiToolLabelPropertiesProjectScopesItem"]] = rest_field( + name="projectScopes", visibility=["read", "create", "update", "delete", "query"] + ) + """List of project-level tool label definitions.""" + + @overload + def __init__( + self, + *, + tool_connection_name: str, + account_scope: Optional["_models.RaiToolLabelPropertiesAccountScope"] = None, + project_scopes: Optional[list["_models.RaiToolLabelPropertiesProjectScopesItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiToolLabelPropertiesAccountScope(_Model): + """Account-level tool label definition. + + :ivar label_values: Dictionary of label key-value pairs for the account scope. + :vartype label_values: dict[str, str] + """ + + label_values: Optional[dict[str, str]] = rest_field( + name="labelValues", visibility=["read", "create", "update", "delete", "query"] + ) + """Dictionary of label key-value pairs for the account scope.""" + + @overload + def __init__( + self, + *, + label_values: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiToolLabelPropertiesProjectScopesItem(_Model): + """RaiToolLabelPropertiesProjectScopesItem. + + :ivar project: Project name to which this scope applies. Required. + :vartype project: str + :ivar label_values: Dictionary of label key-value pairs for the project scope. Required. + :vartype label_values: dict[str, str] + """ + + project: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Project name to which this scope applies. Required.""" + label_values: dict[str, str] = rest_field( + name="labelValues", visibility=["read", "create", "update", "delete", "query"] + ) + """Dictionary of label key-value pairs for the project scope. Required.""" + + @overload + def __init__( + self, + *, + project: str, + label_values: dict[str, str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiTopic(ProxyResource): + """Cognitive Services Rai Topic. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cognitiveservices.models.SystemData + :ivar properties: Properties of Cognitive Services Rai Topic. + :vartype properties: ~azure.mgmt.cognitiveservices.models.RaiTopicProperties + :ivar etag: Resource Etag. + :vartype etag: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + properties: Optional["_models.RaiTopicProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of Cognitive Services Rai Topic.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """Resource Etag.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.RaiTopicProperties"] = None, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RaiTopicProperties(_Model): + """RAI Custom Topic properties. + + :ivar topic_id: The unique identifier of the custom topic. + :vartype topic_id: str + :ivar topic_name: The name of the custom topic. + :vartype topic_name: str + :ivar description: Description of the custom topic. + :vartype description: str + :ivar sample_blob_url: Sample blob url for the custom topic. + :vartype sample_blob_url: str + :ivar status: Status of the custom topic. + :vartype status: str + :ivar failed_reason: Failed reason if the status is Failed. + :vartype failed_reason: str + :ivar created_at: Creation time of the custom topic. + :vartype created_at: ~datetime.datetime + :ivar last_modified_at: Last modified time of the custom topic. + :vartype last_modified_at: ~datetime.datetime + """ + + topic_id: Optional[str] = rest_field(name="topicId", visibility=["read", "create", "update", "delete", "query"]) + """The unique identifier of the custom topic.""" + topic_name: Optional[str] = rest_field(name="topicName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the custom topic.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the custom topic.""" + sample_blob_url: Optional[str] = rest_field( + name="sampleBlobUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Sample blob url for the custom topic.""" + status: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Status of the custom topic.""" + failed_reason: Optional[str] = rest_field( + name="failedReason", visibility=["read", "create", "update", "delete", "query"] + ) + """Failed reason if the status is Failed.""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Creation time of the custom topic.""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last modified time of the custom topic.""" + + @overload + def __init__( + self, + *, + topic_id: Optional[str] = None, + topic_name: Optional[str] = None, + description: Optional[str] = None, + sample_blob_url: Optional[str] = None, + status: Optional[str] = None, + failed_reason: Optional[str] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegenerateKeyParameters(_Model): + """Regenerate key parameters. + + :ivar key_name: key name to generate (Key1|Key2). Required. Known values are: "Key1" and + "Key2". + :vartype key_name: str or ~azure.mgmt.cognitiveservices.models.KeyName + """ + + key_name: Union[str, "_models.KeyName"] = rest_field( + name="keyName", visibility=["read", "create", "update", "delete", "query"] + ) + """key name to generate (Key1|Key2). Required. Known values are: \"Key1\" and \"Key2\".""" + + @overload + def __init__( + self, + *, + key_name: Union[str, "_models.KeyName"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegionSetting(_Model): + """The call rate limit Cognitive Services account. + + :ivar name: Name of the region. + :vartype name: str + :ivar value: A value for priority or weighted routing methods. + :vartype value: float + :ivar customsubdomain: Maps the region to the regional custom subdomain. + :vartype customsubdomain: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the region.""" + value: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A value for priority or weighted routing methods.""" + customsubdomain: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Maps the region to the regional custom subdomain.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[float] = None, + customsubdomain: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ReplacementConfig(_Model): + """Configuration for model replacement. + + :ivar target_model_name: The name of the replacement model. + :vartype target_model_name: str + :ivar target_model_version: The version of the replacement model. + :vartype target_model_version: str + :ivar auto_upgrade_start_date: The date when automatic upgrade should start. This applies to + deployments with the OnceNewDefaultVersionAvailable upgrade option. + :vartype auto_upgrade_start_date: ~datetime.datetime + :ivar upgrade_on_expiry_lead_time_days: The number of days before deprecation date to trigger + upgrade. This applies to deployments with the OnceCurrentVersionExpired upgrade option. + :vartype upgrade_on_expiry_lead_time_days: int + """ + + target_model_name: Optional[str] = rest_field( + name="targetModelName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the replacement model.""" + target_model_version: Optional[str] = rest_field( + name="targetModelVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The version of the replacement model.""" + auto_upgrade_start_date: Optional[datetime.datetime] = rest_field( + name="autoUpgradeStartDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date when automatic upgrade should start. This applies to deployments with the + OnceNewDefaultVersionAvailable upgrade option.""" + upgrade_on_expiry_lead_time_days: Optional[int] = rest_field( + name="upgradeOnExpiryLeadTimeDays", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of days before deprecation date to trigger upgrade. This applies to deployments with + the OnceCurrentVersionExpired upgrade option.""" + + @overload + def __init__( + self, + *, + target_model_name: Optional[str] = None, + target_model_version: Optional[str] = None, + auto_upgrade_start_date: Optional[datetime.datetime] = None, + upgrade_on_expiry_lead_time_days: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RequestMatchPattern(_Model): + """RequestMatchPattern. + + :ivar path: + :vartype path: str + :ivar method: + :vartype method: str + """ + + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + method: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + path: Optional[str] = None, + method: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceSku(_Model): + """Describes an available Cognitive Services SKU. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: The name of SKU. + :vartype name: str + :ivar tier: Specifies the tier of Cognitive Services account. + :vartype tier: str + :ivar kind: The Kind of resources that are supported in this SKU. + :vartype kind: str + :ivar locations: The set of locations that the SKU is available. + :vartype locations: list[str] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictions] + """ + + resource_type: Optional[str] = rest_field( + name="resourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of resource the SKU applies to.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of SKU.""" + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Specifies the tier of Cognitive Services account.""" + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Kind of resources that are supported in this SKU.""" + locations: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The set of locations that the SKU is available.""" + restrictions: Optional[list["_models.ResourceSkuRestrictions"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The restrictions because of which SKU cannot be used. This is empty if there are no + restrictions.""" + + @overload + def __init__( + self, + *, + resource_type: Optional[str] = None, + name: Optional[str] = None, + tier: Optional[str] = None, + kind: Optional[str] = None, + locations: Optional[list[str]] = None, + restrictions: Optional[list["_models.ResourceSkuRestrictions"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceSkuRestrictionInfo(_Model): + """ResourceSkuRestrictionInfo. + + :ivar locations: Locations where the SKU is restricted. + :vartype locations: list[str] + :ivar zones: List of availability zones where the SKU is restricted. + :vartype zones: list[str] + """ + + locations: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Locations where the SKU is restricted.""" + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of availability zones where the SKU is restricted.""" + + @overload + def __init__( + self, + *, + locations: Optional[list[str]] = None, + zones: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceSkuRestrictions(_Model): + """Describes restrictions of a SKU. + + :ivar type: The type of restrictions. Known values are: "Location" and "Zone". + :vartype type: str or ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsType + :ivar values_property: The value of restrictions. If the restriction type is set to location. + This would be different locations where the SKU is restricted. + :vartype values_property: list[str] + :ivar restriction_info: The information about the restriction where the SKU cannot be used. + :vartype restriction_info: ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionInfo + :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and + "NotAvailableForSubscription". + :vartype reason_code: str or + ~azure.mgmt.cognitiveservices.models.ResourceSkuRestrictionsReasonCode + """ + + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of restrictions. Known values are: \"Location\" and \"Zone\".""" + values_property: Optional[list[str]] = rest_field( + name="values", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="values" + ) + """The value of restrictions. If the restriction type is set to location. This would be different + locations where the SKU is restricted.""" + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = rest_field( + name="restrictionInfo", visibility=["read", "create", "update", "delete", "query"] + ) + """The information about the restriction where the SKU cannot be used.""" + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = rest_field( + name="reasonCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The reason for restriction. Known values are: \"QuotaId\" and \"NotAvailableForSubscription\".""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceSkuRestrictionsType"]] = None, + values_property: Optional[list[str]] = None, + restriction_info: Optional["_models.ResourceSkuRestrictionInfo"] = None, + reason_code: Optional[Union[str, "_models.ResourceSkuRestrictionsReasonCode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RoleBasedBuiltInAuthorizationPolicy(ApplicationAuthorizationPolicy, discriminator="Default"): + """Built-in role-based authorization policy. + + :ivar type: Authorization scheme type. Required. Standard AzureML RBAC. + :vartype type: str or ~azure.mgmt.cognitiveservices.models.DEFAULT + """ + + type: Literal[BuiltInAuthorizationScheme.DEFAULT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authorization scheme type. Required. Standard AzureML RBAC.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = BuiltInAuthorizationScheme.DEFAULT # type: ignore + + +class RootError(_Model): + """Error details associated with compute resource operations. + + :ivar code: + :vartype code: str + :ivar message: + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SafetyProviderConfig(RaiSafetyProviderConfig): + """Gets or sets the source to which safety providers applies. + + :ivar safety_provider_name: Name of RAI Safety Provider. + :vartype safety_provider_name: str + :ivar blocking: If blocking would occur. + :vartype blocking: bool + :ivar source: Content source to apply the Content Filters. Known values are: "Prompt", + "Completion", "PreToolCall", "PostToolCall", "PreRun", and "PostRun". + :vartype source: str or ~azure.mgmt.cognitiveservices.models.RaiPolicyContentSource + """ + + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Content source to apply the Content Filters. Known values are: \"Prompt\", \"Completion\", + \"PreToolCall\", \"PostToolCall\", \"PreRun\", and \"PostRun\".""" + + @overload + def __init__( + self, + *, + safety_provider_name: Optional[str] = None, + blocking: Optional[bool] = None, + source: Optional[Union[str, "_models.RaiPolicyContentSource"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SASAuthTypeConnectionProperties(ConnectionPropertiesV2, discriminator="SAS"): + """SASAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionSharedAccessSignature + :ivar auth_type: Authentication type of the connection target. Required. SAS. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.SAS + """ + + credentials: Optional["_models.ConnectionSharedAccessSignature"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auth_type: Literal[ConnectionAuthType.SAS] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. SAS.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionSharedAccessSignature"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.SAS # type: ignore + + +class ServicePrincipalAuthTypeConnectionProperties( + ConnectionPropertiesV2, discriminator="ServicePrincipal" +): # pylint: disable=name-too-long + """ServicePrincipalAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionServicePrincipal + :ivar auth_type: Authentication type of the connection target. Required. SERVICE_PRINCIPAL. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.SERVICE_PRINCIPAL + """ + + credentials: Optional["_models.ConnectionServicePrincipal"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auth_type: Literal[ConnectionAuthType.SERVICE_PRINCIPAL] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. SERVICE_PRINCIPAL.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionServicePrincipal"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.SERVICE_PRINCIPAL # type: ignore + + +class Sku(_Model): + """The resource model definition representing SKU. + + :ivar name: The name of the SKU. Ex - P3. It is typically a letter+number code. Required. + :vartype name: str + :ivar tier: This field is required to be implemented by the Resource Provider if the service + has more than one tier, but is not required on a PUT. Known values are: "Free", "Basic", + "Standard", "Premium", and "Enterprise". + :vartype tier: str or ~azure.mgmt.cognitiveservices.models.SkuTier + :ivar size: The SKU size. When the name field is the combination of tier and some other value, + this would be the standalone code. + :vartype size: str + :ivar family: If the service has different generations of hardware, for the same SKU, then that + can be captured here. + :vartype family: str + :ivar capacity: If the SKU supports scale out/in then the capacity integer should be included. + If scale out/in is not possible for the resource this may be omitted. + :vartype capacity: int + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the SKU. Ex - P3. It is typically a letter+number code. Required.""" + tier: Optional[Union[str, "_models.SkuTier"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """This field is required to be implemented by the Resource Provider if the service has more than + one tier, but is not required on a PUT. Known values are: \"Free\", \"Basic\", \"Standard\", + \"Premium\", and \"Enterprise\".""" + size: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The SKU size. When the name field is the combination of tier and some other value, this would + be the standalone code.""" + family: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If the service has different generations of hardware, for the same SKU, then that can be + captured here.""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If the SKU supports scale out/in then the capacity integer should be included. If scale out/in + is not possible for the resource this may be omitted.""" + + @overload + def __init__( + self, + *, + name: str, + tier: Optional[Union[str, "_models.SkuTier"]] = None, + size: Optional[str] = None, + family: Optional[str] = None, + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuAvailability(_Model): + """SKU availability. + + :ivar kind: The kind (type) of cognitive service account. + :vartype kind: str + :ivar type: The Type of the resource. + :vartype type: str + :ivar sku_name: The name of SKU. + :vartype sku_name: str + :ivar sku_available: Indicates the given SKU is available or not. + :vartype sku_available: bool + :ivar reason: Reason why the SKU is not available. + :vartype reason: str + :ivar message: Additional error message. + :vartype message: str + """ + + kind: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The kind (type) of cognitive service account.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The Type of the resource.""" + sku_name: Optional[str] = rest_field(name="skuName", visibility=["read", "create", "update", "delete", "query"]) + """The name of SKU.""" + sku_available: Optional[bool] = rest_field( + name="skuAvailable", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates the given SKU is available or not.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Reason why the SKU is not available.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Additional error message.""" + + @overload + def __init__( + self, + *, + kind: Optional[str] = None, + type: Optional[str] = None, + sku_name: Optional[str] = None, + sku_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuAvailabilityListResult(_Model): + """Check SKU availability result list. + + :ivar value: Check SKU availability result list. + :vartype value: list[~azure.mgmt.cognitiveservices.models.SkuAvailability] + """ + + value: Optional[list["_models.SkuAvailability"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Check SKU availability result list.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.SkuAvailability"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuCapability(_Model): + """SkuCapability indicates the capability of a certain feature. + + :ivar name: The name of the SkuCapability. + :vartype name: str + :ivar value: The value of the SkuCapability. + :vartype value: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the SkuCapability.""" + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The value of the SkuCapability.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuChangeInfo(_Model): + """Sku change info of account. + + :ivar count_of_downgrades: Gets the count of downgrades. + :vartype count_of_downgrades: float + :ivar count_of_upgrades_after_downgrades: Gets the count of upgrades after downgrades. + :vartype count_of_upgrades_after_downgrades: float + :ivar last_change_date: Gets the last change date. + :vartype last_change_date: str + """ + + count_of_downgrades: Optional[float] = rest_field( + name="countOfDowngrades", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the count of downgrades.""" + count_of_upgrades_after_downgrades: Optional[float] = rest_field( + name="countOfUpgradesAfterDowngrades", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the count of upgrades after downgrades.""" + last_change_date: Optional[str] = rest_field( + name="lastChangeDate", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the last change date.""" + + @overload + def __init__( + self, + *, + count_of_downgrades: Optional[float] = None, + count_of_upgrades_after_downgrades: Optional[float] = None, + last_change_date: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SkuResource(_Model): + """Properties of Cognitive Services account resource sku resource properties. + + :ivar resource_type: The resource type name. + :vartype resource_type: str + :ivar sku: The resource model definition representing SKU. + :vartype sku: ~azure.mgmt.cognitiveservices.models.Sku + :ivar capacity: The capacity configuration. + :vartype capacity: ~azure.mgmt.cognitiveservices.models.CapacityConfig + """ + + resource_type: Optional[str] = rest_field( + name="resourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource type name.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource model definition representing SKU.""" + capacity: Optional["_models.CapacityConfig"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The capacity configuration.""" + + @overload + def __init__( + self, + *, + resource_type: Optional[str] = None, + sku: Optional["_models.Sku"] = None, + capacity: Optional["_models.CapacityConfig"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.cognitiveservices.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ThrottlingRule(_Model): + """ThrottlingRule. + + :ivar key: + :vartype key: str + :ivar renewal_period: + :vartype renewal_period: float + :ivar count: + :vartype count: float + :ivar min_count: + :vartype min_count: float + :ivar dynamic_throttling_enabled: + :vartype dynamic_throttling_enabled: bool + :ivar match_patterns: + :vartype match_patterns: list[~azure.mgmt.cognitiveservices.models.RequestMatchPattern] + """ + + key: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + renewal_period: Optional[float] = rest_field( + name="renewalPeriod", visibility=["read", "create", "update", "delete", "query"] + ) + count: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + min_count: Optional[float] = rest_field(name="minCount", visibility=["read", "create", "update", "delete", "query"]) + dynamic_throttling_enabled: Optional[bool] = rest_field( + name="dynamicThrottlingEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + match_patterns: Optional[list["_models.RequestMatchPattern"]] = rest_field( + name="matchPatterns", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + key: Optional[str] = None, + renewal_period: Optional[float] = None, + count: Optional[float] = None, + min_count: Optional[float] = None, + dynamic_throttling_enabled: Optional[bool] = None, + match_patterns: Optional[list["_models.RequestMatchPattern"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrafficRoutingRule(_Model): + """Represents a rule for routing traffic to a specific deployment. + + :ivar rule_id: The identifier of this traffic routing rule. + :vartype rule_id: str + :ivar description: A user-provided description for this traffic routing rule. + :vartype description: str + :ivar deployment_id: The unique identifier of the deployment to which traffic is routed by this + rule. + :vartype deployment_id: str + :ivar traffic_percentage: Gets or sets the percentage of traffic allocated to this instance. + :vartype traffic_percentage: int + """ + + rule_id: Optional[str] = rest_field(name="ruleId", visibility=["read", "create", "update", "delete", "query"]) + """The identifier of this traffic routing rule.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A user-provided description for this traffic routing rule.""" + deployment_id: Optional[str] = rest_field( + name="deploymentId", visibility=["read", "create", "update", "delete", "query"] + ) + """The unique identifier of the deployment to which traffic is routed by this rule.""" + traffic_percentage: Optional[int] = rest_field( + name="trafficPercentage", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets or sets the percentage of traffic allocated to this instance.""" + + @overload + def __init__( + self, + *, + rule_id: Optional[str] = None, + description: Optional[str] = None, + deployment_id: Optional[str] = None, + traffic_percentage: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Usage(_Model): + """The usage data for a usage request. + + :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", + "CountPerSecond", "BytesPerSecond", and "Milliseconds". + :vartype unit: str or ~azure.mgmt.cognitiveservices.models.UnitType + :ivar name: The name information for the metric. + :vartype name: ~azure.mgmt.cognitiveservices.models.MetricName + :ivar quota_period: The quota period used to summarize the usage values. + :vartype quota_period: str + :ivar limit: Maximum value for this metric. + :vartype limit: float + :ivar current_value: Current value for this metric. + :vartype current_value: float + :ivar next_reset_time: Next reset time for current quota. + :vartype next_reset_time: str + :ivar status: Cognitive Services account quota usage status. Known values are: "Included", + "Blocked", "InOverage", and "Unknown". + :vartype status: str or ~azure.mgmt.cognitiveservices.models.QuotaUsageStatus + """ + + unit: Optional[Union[str, "_models.UnitType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The unit of the metric. Known values are: \"Count\", \"Bytes\", \"Seconds\", \"Percent\", + \"CountPerSecond\", \"BytesPerSecond\", and \"Milliseconds\".""" + name: Optional["_models.MetricName"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name information for the metric.""" + quota_period: Optional[str] = rest_field( + name="quotaPeriod", visibility=["read", "create", "update", "delete", "query"] + ) + """The quota period used to summarize the usage values.""" + limit: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Maximum value for this metric.""" + current_value: Optional[float] = rest_field( + name="currentValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Current value for this metric.""" + next_reset_time: Optional[str] = rest_field( + name="nextResetTime", visibility=["read", "create", "update", "delete", "query"] + ) + """Next reset time for current quota.""" + status: Optional[Union[str, "_models.QuotaUsageStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Cognitive Services account quota usage status. Known values are: \"Included\", \"Blocked\", + \"InOverage\", and \"Unknown\".""" + + @overload + def __init__( + self, + *, + unit: Optional[Union[str, "_models.UnitType"]] = None, + name: Optional["_models.MetricName"] = None, + quota_period: Optional[str] = None, + limit: Optional[float] = None, + current_value: Optional[float] = None, + next_reset_time: Optional[str] = None, + status: Optional[Union[str, "_models.QuotaUsageStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UsageListResult(_Model): + """The response to a list usage request. + + :ivar next_link: The link used to get the next page of Usages. + :vartype next_link: str + :ivar value: The list of usages for Cognitive Service account. + :vartype value: list[~azure.mgmt.cognitiveservices.models.Usage] + """ + + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link used to get the next page of Usages.""" + value: Optional[list["_models.Usage"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The list of usages for Cognitive Service account.""" + + @overload + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[list["_models.Usage"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedIdentity(_Model): + """User-assigned managed identity. + + :ivar principal_id: Azure Active Directory principal ID associated with this Identity. + :vartype principal_id: str + :ivar client_id: Client App Id associated with this identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """Azure Active Directory principal ID associated with this Identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """Client App Id associated with this identity.""" + + +class UsernamePasswordAuthTypeConnectionProperties( + ConnectionPropertiesV2, discriminator="UsernamePassword" +): # pylint: disable=name-too-long + """UsernamePasswordAuthTypeConnectionProperties. + + :ivar category: Category of the connection. Known values are: "PythonFeed", + "ContainerRegistry", "Git", "S3", "Snowflake", "AzureKeyVault", "AzureSqlDb", + "AzureSynapseAnalytics", "AzureMySqlDb", "AzurePostgresDb", "ADLSGen2", + "AzureContainerAppEnvironment", "Redis", "ApiKey", "AzureOpenAI", "AIServices", + "CognitiveSearch", "CognitiveService", "CustomKeys", "AzureBlob", "AzureStorageAccount", + "AzureOneLake", "CosmosDb", "CosmosDbMongoDbApi", "AzureDataExplorer", "AzureMariaDb", + "AzureDatabricksDeltaLake", "AzureSqlMi", "AzureTableStorage", "AmazonRdsForOracle", + "AmazonRdsForSqlServer", "AmazonRedshift", "Db2", "Drill", "GoogleBigQuery", "Greenplum", + "Hbase", "Hive", "Impala", "Informix", "MariaDb", "MicrosoftAccess", "MySql", "Netezza", + "Oracle", "Phoenix", "PostgreSql", "Presto", "SapOpenHub", "SapBw", "SapHana", "SapTable", + "Spark", "SqlServer", "Sybase", "Teradata", "Vertica", "Pinecone", "Databricks", "Cassandra", + "Couchbase", "MongoDbV2", "MongoDbAtlas", "AmazonS3Compatible", "FileServer", "FtpServer", + "GoogleCloudStorage", "Hdfs", "OracleCloudStorage", "Sftp", "GenericHttp", "ODataRest", "Odbc", + "GenericRest", "RemoteTool", "AmazonMws", "Concur", "Dynamics", "DynamicsAx", "DynamicsCrm", + "GoogleAdWords", "Hubspot", "Jira", "Magento", "Marketo", "Office365", "Eloqua", "Responsys", + "OracleServiceCloud", "PayPal", "QuickBooks", "Salesforce", "SalesforceServiceCloud", + "SalesforceMarketingCloud", "SapCloudForCustomer", "SapEcc", "ServiceNow", + "SharePointOnlineList", "Shopify", "Square", "WebTable", "Xero", "Zoho", + "GenericContainerRegistry", "Elasticsearch", "AppInsights", "AppConfig", "OpenAI", "Serp", + "BingLLMSearch", "Serverless", "ManagedOnlineEndpoint", "ApiManagement", "ModelGateway", + "GroundingWithBingSearch", "GroundingWithCustomSearch", "Sharepoint", "MicrosoftFabric", + "PowerPlatformEnvironment", and "RemoteA2A". + :vartype category: str or ~azure.mgmt.cognitiveservices.models.ConnectionCategory + :ivar created_by_workspace_arm_id: + :vartype created_by_workspace_arm_id: str + :ivar error: Provides the error message if the connection fails. + :vartype error: str + :ivar expiry_time: + :vartype expiry_time: ~datetime.datetime + :ivar group: Group based on connection category. Known values are: "Azure", "AzureAI", + "Database", "NoSQL", "File", "GenericProtocol", and "ServicesAndApps". + :vartype group: str or ~azure.mgmt.cognitiveservices.models.ConnectionGroup + :ivar is_shared_to_all: + :vartype is_shared_to_all: bool + :ivar metadata: Store user metadata for this connection. + :vartype metadata: dict[str, str] + :ivar pe_requirement: Specifies how private endpoints are used with this connection: + 'Required', 'NotRequired', or 'NotApplicable'. Known values are: "Required", "NotRequired", and + "NotApplicable". + :vartype pe_requirement: str or ~azure.mgmt.cognitiveservices.models.ManagedPERequirement + :ivar pe_status: Specifies the status of private endpoints for this connection: 'Inactive', + 'Active', or 'NotApplicable'. Known values are: "Inactive", "Active", and "NotApplicable". + :vartype pe_status: str or ~azure.mgmt.cognitiveservices.models.ManagedPEStatus + :ivar shared_user_list: + :vartype shared_user_list: list[str] + :ivar target: The connection URL to be used. + :vartype target: str + :ivar use_workspace_managed_identity: + :vartype use_workspace_managed_identity: bool + :ivar credentials: + :vartype credentials: ~azure.mgmt.cognitiveservices.models.ConnectionUsernamePassword + :ivar auth_type: Authentication type of the connection target. Required. USERNAME_PASSWORD. + :vartype auth_type: str or ~azure.mgmt.cognitiveservices.models.USERNAME_PASSWORD + """ + + credentials: Optional["_models.ConnectionUsernamePassword"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + auth_type: Literal[ConnectionAuthType.USERNAME_PASSWORD] = rest_discriminator(name="authType", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Authentication type of the connection target. Required. USERNAME_PASSWORD.""" + + @overload + def __init__( + self, + *, + category: Optional[Union[str, "_models.ConnectionCategory"]] = None, + error: Optional[str] = None, + expiry_time: Optional[datetime.datetime] = None, + is_shared_to_all: Optional[bool] = None, + metadata: Optional[dict[str, str]] = None, + pe_requirement: Optional[Union[str, "_models.ManagedPERequirement"]] = None, + pe_status: Optional[Union[str, "_models.ManagedPEStatus"]] = None, + shared_user_list: Optional[list[str]] = None, + target: Optional[str] = None, + use_workspace_managed_identity: Optional[bool] = None, + credentials: Optional["_models.ConnectionUsernamePassword"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.auth_type = ConnectionAuthType.USERNAME_PASSWORD # type: ignore + + +class UserOwnedAmlWorkspace(_Model): + """The user owned AML account for Cognitive Services account. + + :ivar resource_id: Full resource id of a AML account resource. + :vartype resource_id: str + :ivar identity_client_id: Identity Client id of a AML account resource. + :vartype identity_client_id: str + """ + + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Full resource id of a AML account resource.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identity Client id of a AML account resource.""" + + @overload + def __init__( + self, + *, + resource_id: Optional[str] = None, + identity_client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserOwnedStorage(_Model): + """The user owned storage for Cognitive Services account. + + :ivar resource_id: Full resource id of a Microsoft.Storage resource. + :vartype resource_id: str + :ivar identity_client_id: + :vartype identity_client_id: str + """ + + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Full resource id of a Microsoft.Storage resource.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + resource_id: Optional[str] = None, + identity_client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VersionedAgentReference(AgentReferenceProperties): + """Type modeling a reference to a version of an agent definition. + + :ivar agent_id: Gets the agent's unique identifier within the organization (subscription). + :vartype agent_id: str + :ivar agent_name: Gets the agent's name (unique within the project/app). + :vartype agent_name: str + :ivar agent_version: Gets the agent's version (unique for each agent lineage). + :vartype agent_version: str + """ + + agent_version: Optional[str] = rest_field( + name="agentVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the agent's version (unique for each agent lineage).""" + + @overload + def __init__( + self, + *, + agent_id: Optional[str] = None, + agent_name: Optional[str] = None, + agent_version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VirtualNetworkRule(_Model): + """A rule governing the accessibility from a specific virtual network. + + :ivar id: Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + Required. + :vartype id: str + :ivar state: Gets the state of virtual network rule. + :vartype state: str + :ivar ignore_missing_vnet_service_endpoint: Ignore missing vnet service endpoint or not. + :vartype ignore_missing_vnet_service_endpoint: bool + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Full resource id of a vnet subnet, such as + '/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1'. + Required.""" + state: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets the state of virtual network rule.""" + ignore_missing_vnet_service_endpoint: Optional[bool] = rest_field( + name="ignoreMissingVnetServiceEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Ignore missing vnet service endpoint or not.""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + state: Optional[str] = None, + ignore_missing_vnet_service_endpoint: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py index cac37cb8c8a9..5dd741ca6d41 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/__init__.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,67 +13,91 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._accounts_operations import AccountsOperations # type: ignore -from ._deleted_accounts_operations import DeletedAccountsOperations # type: ignore -from ._resource_skus_operations import ResourceSkusOperations # type: ignore -from ._usages_operations import UsagesOperations # type: ignore from ._operations import Operations # type: ignore -from ._cognitive_services_management_client_operations import _CognitiveServicesManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import -from ._commitment_tiers_operations import CommitmentTiersOperations # type: ignore -from ._models_operations import ModelsOperations # type: ignore -from ._location_based_model_capacities_operations import LocationBasedModelCapacitiesOperations # type: ignore -from ._model_capacities_operations import ModelCapacitiesOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._deployments_operations import DeploymentsOperations # type: ignore -from ._commitment_plans_operations import CommitmentPlansOperations # type: ignore -from ._encryption_scopes_operations import EncryptionScopesOperations # type: ignore -from ._rai_policies_operations import RaiPoliciesOperations # type: ignore -from ._rai_blocklists_operations import RaiBlocklistsOperations # type: ignore -from ._rai_blocklist_items_operations import RaiBlocklistItemsOperations # type: ignore -from ._rai_topics_operations import RaiTopicsOperations # type: ignore -from ._rai_content_filters_operations import RaiContentFiltersOperations # type: ignore -from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore -from ._defender_for_ai_settings_operations import DefenderForAISettingsOperations # type: ignore -from ._projects_operations import ProjectsOperations # type: ignore -from ._account_connections_operations import AccountConnectionsOperations # type: ignore -from ._project_connections_operations import ProjectConnectionsOperations # type: ignore -from ._account_capability_hosts_operations import AccountCapabilityHostsOperations # type: ignore -from ._project_capability_hosts_operations import ProjectCapabilityHostsOperations # type: ignore -from ._quota_tiers_operations import QuotaTiersOperations # type: ignore +from ._operations import AccountsOperations # type: ignore +from ._operations import DeletedAccountsOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import DeploymentsOperations # type: ignore +from ._operations import CommitmentPlansOperations # type: ignore +from ._operations import EncryptionScopesOperations # type: ignore +from ._operations import RaiPoliciesOperations # type: ignore +from ._operations import SubscriptionRaiPolicyOperations # type: ignore +from ._operations import RaiBlocklistItemsOperations # type: ignore +from ._operations import RaiBlocklistsOperations # type: ignore +from ._operations import RaiTopicsOperations # type: ignore +from ._operations import RaiToolLabelsOperations # type: ignore +from ._operations import RaiContentFiltersOperations # type: ignore +from ._operations import NetworkSecurityPerimeterConfigurationsOperations # type: ignore +from ._operations import DefenderForAISettingsOperations # type: ignore +from ._operations import ProjectsOperations # type: ignore +from ._operations import ProjectConnectionsOperations # type: ignore +from ._operations import ProjectCapabilityHostsOperations # type: ignore +from ._operations import QuotaTiersOperations # type: ignore +from ._operations import AgentApplicationsOperations # type: ignore +from ._operations import ComputesOperations # type: ignore +from ._operations import PrivateLinkResourcesOperations # type: ignore +from ._operations import TestRaiExternalSafetyProviderOperations # type: ignore +from ._operations import ManagedNetworkProvisionsOperations # type: ignore +from ._operations import RaiExternalSafetyProviderOperations # type: ignore +from ._operations import RaiExternalSafetyProvidersOperations # type: ignore +from ._operations import AccountConnectionsOperations # type: ignore +from ._operations import AccountCapabilityHostsOperations # type: ignore +from ._operations import OutboundRuleOperations # type: ignore +from ._operations import ManagedNetworkSettingsOperations # type: ignore +from ._operations import OutboundRulesOperations # type: ignore +from ._operations import AgentDeploymentsOperations # type: ignore +from ._operations import ResourceSkusOperations # type: ignore +from ._operations import UsagesOperations # type: ignore +from ._operations import CommitmentTiersOperations # type: ignore +from ._operations import ModelsOperations # type: ignore +from ._operations import LocationBasedModelCapacitiesOperations # type: ignore +from ._operations import ModelCapacitiesOperations # type: ignore +from ._operations import _CognitiveServicesManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Operations", "AccountsOperations", "DeletedAccountsOperations", - "ResourceSkusOperations", - "UsagesOperations", - "Operations", - "CommitmentTiersOperations", - "ModelsOperations", - "LocationBasedModelCapacitiesOperations", - "ModelCapacitiesOperations", "PrivateEndpointConnectionsOperations", - "PrivateLinkResourcesOperations", "DeploymentsOperations", "CommitmentPlansOperations", "EncryptionScopesOperations", "RaiPoliciesOperations", - "RaiBlocklistsOperations", + "SubscriptionRaiPolicyOperations", "RaiBlocklistItemsOperations", + "RaiBlocklistsOperations", "RaiTopicsOperations", + "RaiToolLabelsOperations", "RaiContentFiltersOperations", "NetworkSecurityPerimeterConfigurationsOperations", "DefenderForAISettingsOperations", "ProjectsOperations", - "AccountConnectionsOperations", "ProjectConnectionsOperations", - "AccountCapabilityHostsOperations", "ProjectCapabilityHostsOperations", "QuotaTiersOperations", + "AgentApplicationsOperations", + "ComputesOperations", + "PrivateLinkResourcesOperations", + "TestRaiExternalSafetyProviderOperations", + "ManagedNetworkProvisionsOperations", + "RaiExternalSafetyProviderOperations", + "RaiExternalSafetyProvidersOperations", + "AccountConnectionsOperations", + "AccountCapabilityHostsOperations", + "OutboundRuleOperations", + "ManagedNetworkSettingsOperations", + "OutboundRulesOperations", + "AgentDeploymentsOperations", + "ResourceSkusOperations", + "UsagesOperations", + "CommitmentTiersOperations", + "ModelsOperations", + "LocationBasedModelCapacitiesOperations", + "ModelCapacitiesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py index 40ef681224ea..1c7c2d228f57 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/azure/mgmt/cognitiveservices/operations/_operations.py @@ -1,12 +1,15 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import PipelineClient @@ -16,36 +19,43 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._configuration import CognitiveServicesManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer +from .._utils.utils import ClientMixinABC T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.CognitiveServices/operations") + _url = "/providers/Microsoft.CognitiveServices/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -56,6 +66,4406 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_accounts_get_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_create_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_update_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_delete_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_accounts_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_list_keys_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_regenerate_key_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_list_skus_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_list_usages_request( + resource_group_name: str, account_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_accounts_list_models_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/models" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deleted_accounts_get_request( + location: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deleted_accounts_purge_request( + location: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/resourceGroups/{resourceGroupName}/deletedAccounts/{accountName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_deleted_accounts_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/deletedAccounts" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_get_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connections_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_private_endpoint_connections_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_get_request( + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_update_request( + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_delete_request( + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_deployments_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_list_skus_request( + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_pause_request( + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}/pause" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_resume_request( + resource_group_name: str, account_name: str, deployment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/deployments/{deploymentName}/resume" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_get_request( + resource_group_name: str, account_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_delete_request( + resource_group_name: str, account_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_commitment_plans_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/commitmentPlans" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_get_plan_request( + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_create_or_update_plan_request( # pylint: disable=name-too-long + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_update_plan_request( # pylint: disable=name-too-long + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_delete_plan_request( # pylint: disable=name-too-long + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_commitment_plans_list_plans_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_list_plans_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/commitmentPlans" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_get_association_request( # pylint: disable=name-too-long + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + "commitmentPlanAssociationName": _SERIALIZER.url( + "commitment_plan_association_name", commitment_plan_association_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_create_or_update_association_request( # pylint: disable=name-too-long + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + "commitmentPlanAssociationName": _SERIALIZER.url( + "commitment_plan_association_name", commitment_plan_association_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_plans_delete_association_request( # pylint: disable=name-too-long + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations/{commitmentPlanAssociationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + "commitmentPlanAssociationName": _SERIALIZER.url( + "commitment_plan_association_name", commitment_plan_association_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_commitment_plans_list_associations_request( # pylint: disable=name-too-long + resource_group_name: str, commitment_plan_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/commitmentPlans/{commitmentPlanName}/accountAssociations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "commitmentPlanName": _SERIALIZER.url("commitment_plan_name", commitment_plan_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_encryption_scopes_get_request( + resource_group_name: str, account_name: str, encryption_scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_encryption_scopes_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, encryption_scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_encryption_scopes_delete_request( + resource_group_name: str, account_name: str, encryption_scope_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes/{encryptionScopeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_encryption_scopes_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/encryptionScopes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_policies_get_request( + resource_group_name: str, account_name: str, rai_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiPolicyName": _SERIALIZER.url("rai_policy_name", rai_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_policies_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, rai_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiPolicyName": _SERIALIZER.url("rai_policy_name", rai_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_policies_delete_request( + resource_group_name: str, account_name: str, rai_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies/{raiPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiPolicyName": _SERIALIZER.url("rai_policy_name", rai_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_policies_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_rai_policy_get_request( # pylint: disable=name-too-long + rai_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiPolicy/{raiPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "raiPolicyName": _SERIALIZER.url("rai_policy_name", rai_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_rai_policy_create_or_update_request( # pylint: disable=name-too-long + rai_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiPolicy/{raiPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "raiPolicyName": _SERIALIZER.url("rai_policy_name", rai_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_rai_policy_delete_request( # pylint: disable=name-too-long + rai_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiPolicy/{raiPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "raiPolicyName": _SERIALIZER.url("rai_policy_name", rai_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_blocklist_items_get_request( + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + "raiBlocklistItemName": _SERIALIZER.url("rai_blocklist_item_name", rai_blocklist_item_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklist_items_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + "raiBlocklistItemName": _SERIALIZER.url("rai_blocklist_item_name", rai_blocklist_item_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklist_items_delete_request( + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems/{raiBlocklistItemName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + "raiBlocklistItemName": _SERIALIZER.url("rai_blocklist_item_name", rai_blocklist_item_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_blocklist_items_list_request( + resource_group_name: str, account_name: str, rai_blocklist_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/raiBlocklistItems" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklist_items_batch_add_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, rai_blocklist_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/addRaiBlocklistItems" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklist_items_batch_delete_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, rai_blocklist_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}/deleteRaiBlocklistItems" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklists_get_request( + resource_group_name: str, account_name: str, rai_blocklist_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklists_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, rai_blocklist_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_blocklists_delete_request( + resource_group_name: str, account_name: str, rai_blocklist_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists/{raiBlocklistName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiBlocklistName": _SERIALIZER.url("rai_blocklist_name", rai_blocklist_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_blocklists_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiBlocklists" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_topics_get_request( + resource_group_name: str, account_name: str, rai_topic_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raitopics/{raiTopicName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiTopicName": _SERIALIZER.url("rai_topic_name", rai_topic_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_topics_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, rai_topic_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raitopics/{raiTopicName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiTopicName": _SERIALIZER.url("rai_topic_name", rai_topic_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_topics_delete_request( + resource_group_name: str, account_name: str, rai_topic_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raitopics/{raiTopicName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiTopicName": _SERIALIZER.url("rai_topic_name", rai_topic_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_topics_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raitopics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_tool_labels_get_request( + resource_group_name: str, account_name: str, rai_tool_connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiToolLabels/{raiToolConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiToolConnectionName": _SERIALIZER.url("rai_tool_connection_name", rai_tool_connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_tool_labels_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, rai_tool_connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiToolLabels/{raiToolConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiToolConnectionName": _SERIALIZER.url("rai_tool_connection_name", rai_tool_connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_tool_labels_delete_request( + resource_group_name: str, account_name: str, rai_tool_connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiToolLabels/{raiToolConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "raiToolConnectionName": _SERIALIZER.url("rai_tool_connection_name", rai_tool_connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_tool_labels_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/raiToolLabels" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_content_filters_get_request( + location: str, filter_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters/{filterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "filterName": _SERIALIZER.url("filter_name", filter_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_content_filters_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/raiContentFilters" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_security_perimeter_configurations_get_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, nsp_configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "nspConfigurationName": _SERIALIZER.url("nsp_configuration_name", nsp_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_security_perimeter_configurations_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_network_security_perimeter_configurations_reconcile_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, nsp_configuration_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/networkSecurityPerimeterConfigurations/{nspConfigurationName}/reconcile" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "nspConfigurationName": _SERIALIZER.url("nsp_configuration_name", nsp_configuration_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_defender_for_ai_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, defender_for_ai_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "defenderForAISettingName": _SERIALIZER.url( + "defender_for_ai_setting_name", defender_for_ai_setting_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_defender_for_ai_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, defender_for_ai_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "defenderForAISettingName": _SERIALIZER.url( + "defender_for_ai_setting_name", defender_for_ai_setting_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_defender_for_ai_settings_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, defender_for_ai_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings/{defenderForAISettingName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "defenderForAISettingName": _SERIALIZER.url( + "defender_for_ai_setting_name", defender_for_ai_setting_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_defender_for_ai_settings_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/defenderForAISettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_get_request( + resource_group_name: str, account_name: str, project_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_create_request( + resource_group_name: str, account_name: str, project_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_update_request( + resource_group_name: str, account_name: str, project_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_delete_request( + resource_group_name: str, account_name: str, project_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_projects_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_connections_get_request( + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_connections_create_request( + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_connections_update_request( + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_connections_delete_request( + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_project_connections_list_request( + resource_group_name: str, + account_name: str, + project_name: str, + subscription_id: str, + *, + target: Optional[str] = None, + category: Optional[str] = None, + include_all: bool = False, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/connections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if target is not None: + _params["target"] = _SERIALIZER.query("target", target, "str") + if category is not None: + _params["category"] = _SERIALIZER.query("category", category, "str") + if include_all is not None: + _params["includeAll"] = _SERIALIZER.query("include_all", include_all, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_capability_hosts_get_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{capabilityHostName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "capabilityHostName": _SERIALIZER.url("capability_host_name", capability_host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_capability_hosts_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{capabilityHostName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "capabilityHostName": _SERIALIZER.url("capability_host_name", capability_host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_project_capability_hosts_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts/{capabilityHostName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "capabilityHostName": _SERIALIZER.url("capability_host_name", capability_host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_project_capability_hosts_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, project_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/capabilityHosts" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_quota_tiers_get_request(default: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/quotaTiers/{default}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "default": _SERIALIZER.url("default", default, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_quota_tiers_create_or_update_request( # pylint: disable=name-too-long + default: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/quotaTiers/{default}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "default": _SERIALIZER.url("default", default, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_quota_tiers_update_request(default: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/quotaTiers/{default}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "default": _SERIALIZER.url("default", default, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_quota_tiers_list_by_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/quotaTiers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_applications_get_request( + resource_group_name: str, account_name: str, project_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_applications_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, project_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_applications_delete_request( + resource_group_name: str, account_name: str, project_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{name}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_agent_applications_list_request( + resource_group_name: str, + account_name: str, + project_name: str, + subscription_id: str, + *, + count: int = 30, + skip: Optional[int] = None, + skip_token: Optional[str] = None, + names: Optional[List[str]] = None, + search_text: Optional[str] = None, + order_by: Optional[str] = None, + order_by_asc: bool = False, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if count is not None: + _params["count"] = _SERIALIZER.query("count", count, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if names is not None: + _params["names"] = [_SERIALIZER.query("names", q, "str") if q is not None else "" for q in names] + if search_text is not None: + _params["searchText"] = _SERIALIZER.query("search_text", search_text, "str") + if order_by is not None: + _params["orderBy"] = _SERIALIZER.query("order_by", order_by, "str") + if order_by_asc is not None: + _params["orderByAsc"] = _SERIALIZER.query("order_by_asc", order_by_asc, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_applications_list_agents_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, project_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{name}/listAgents" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_applications_enable_request( + resource_group_name: str, account_name: str, project_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{name}/enable" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_agent_applications_disable_request( + resource_group_name: str, account_name: str, project_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{name}/disable" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_computes_get_request( + resource_group_name: str, account_name: str, compute_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/computes/{computeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_computes_create_or_update_request( + resource_group_name: str, account_name: str, compute_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/computes/{computeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_computes_update_request( + resource_group_name: str, account_name: str, compute_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/computes/{computeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_computes_delete_request( + resource_group_name: str, account_name: str, compute_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/computes/{computeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "computeName": _SERIALIZER.url("compute_name", compute_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_computes_list_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/computes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_link_resources_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_rai_external_safety_provider_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, safety_provider_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/testRaiExternalSafetyProvider/{safetyProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "safetyProviderName": _SERIALIZER.url("safety_provider_name", safety_provider_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_network_provisions_provision_managed_network_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/provisionManagedNetwork" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_external_safety_provider_get_request( # pylint: disable=name-too-long + safety_provider_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiExternalSafetyProviders/{safetyProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "safetyProviderName": _SERIALIZER.url("safety_provider_name", safety_provider_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_external_safety_provider_create_or_update_request( # pylint: disable=name-too-long + safety_provider_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiExternalSafetyProviders/{safetyProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "safetyProviderName": _SERIALIZER.url("safety_provider_name", safety_provider_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rai_external_safety_provider_delete_request( # pylint: disable=name-too-long + safety_provider_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiExternalSafetyProviders/{safetyProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "safetyProviderName": _SERIALIZER.url("safety_provider_name", safety_provider_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rai_external_safety_providers_list_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/raiExternalSafetyProviders" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_connections_get_request( + resource_group_name: str, account_name: str, connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_connections_create_request( + resource_group_name: str, account_name: str, connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_connections_update_request( + resource_group_name: str, account_name: str, connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_connections_delete_request( + resource_group_name: str, account_name: str, connection_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/connections/{connectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "connectionName": _SERIALIZER.url("connection_name", connection_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_account_connections_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + target: Optional[str] = None, + category: Optional[str] = None, + include_all: bool = False, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/connections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if target is not None: + _params["target"] = _SERIALIZER.query("target", target, "str") + if category is not None: + _params["category"] = _SERIALIZER.query("category", category, "str") + if include_all is not None: + _params["includeAll"] = _SERIALIZER.query("include_all", include_all, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_capability_hosts_get_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, capability_host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts/{capabilityHostName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "capabilityHostName": _SERIALIZER.url("capability_host_name", capability_host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_capability_hosts_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, capability_host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts/{capabilityHostName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "capabilityHostName": _SERIALIZER.url("capability_host_name", capability_host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_account_capability_hosts_delete_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, capability_host_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts/{capabilityHostName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "capabilityHostName": _SERIALIZER.url("capability_host_name", capability_host_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_account_capability_hosts_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/capabilityHosts" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_rule_get_request( + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}/outboundRules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_rule_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}/outboundRules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_rule_delete_request( + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}/outboundRules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_outbound_rule_list_request( + resource_group_name: str, account_name: str, managed_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}/outboundRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_network_settings_get_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, managed_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_network_settings_put_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, managed_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_network_settings_patch_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, managed_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_network_settings_list_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_outbound_rules_post_request( + resource_group_name: str, account_name: str, managed_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/managedNetworks/{managedNetworkName}/batchOutboundRules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "managedNetworkName": _SERIALIZER.url("managed_network_name", managed_network_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_deployments_get_request( + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{appName}/agentDeployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_deployments_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{appName}/agentDeployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_deployments_delete_request( + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{appName}/agentDeployments/{deploymentName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_agent_deployments_list_request( + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + subscription_id: str, + *, + count: int = 30, + skip_token: Optional[str] = None, + names: Optional[List[str]] = None, + order_by: Optional[str] = None, + order_by_asc: bool = False, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{appName}/agentDeployments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if count is not None: + _params["count"] = _SERIALIZER.query("count", count, "int") + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if names is not None: + _params["names"] = [_SERIALIZER.query("names", q, "str") if q is not None else "" for q in names] + if order_by is not None: + _params["orderBy"] = _SERIALIZER.query("order_by", order_by, "str") + if order_by_asc is not None: + _params["orderByAsc"] = _SERIALIZER.query("order_by_asc", order_by_asc, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agent_deployments_start_request( + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{appName}/agentDeployments/{deploymentName}/start" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_agent_deployments_stop_request( + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/projects/{projectName}/applications/{appName}/agentDeployments/{deploymentName}/stop" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url("account_name", account_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "appName": _SERIALIZER.url("app_name", app_name, "str"), + "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_resource_skus_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_usages_list_request( + location: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_commitment_tiers_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/commitmentTiers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_models_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/models" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_location_based_model_capacities_list_request( # pylint: disable=name-too-long + location: str, subscription_id: str, *, model_format: str, model_name: str, model_version: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/modelCapacities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["modelFormat"] = _SERIALIZER.query("model_format", model_format, "str") + _params["modelName"] = _SERIALIZER.query("model_name", model_name, "str") + _params["modelVersion"] = _SERIALIZER.query("model_version", model_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_model_capacities_list_request( + subscription_id: str, *, model_format: str, model_name: str, model_version: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/modelCapacities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["modelFormat"] = _SERIALIZER.query("model_format", model_format, "str") + _params["modelName"] = _SERIALIZER.query("model_name", model_name, "str") + _params["modelVersion"] = _SERIALIZER.query("model_version", model_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cognitive_services_management_check_sku_availability_request( # pylint: disable=name-too-long + location: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cognitive_services_management_check_domain_availability_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cognitive_services_management_calculate_model_capacity_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/calculateModelCapacity" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -63,10 +4473,19928 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s - :attr:`operations` attribute. + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """Lists all the available Cognitive Services account operations. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`accounts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: + """Returns a Cognitive Services account specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: Account. The Account is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Account + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + + _request = build_accounts_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Account, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(account, (IOBase, bytes)): + _content = account + else: + _content = json.dumps(account, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_accounts_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + account: _models.Account, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + account: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + account: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds + the keys for developer to access intelligent APIs. It's also the resource type for billing. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Is one of the following + types: Account, JSON, IO[bytes] Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account or JSON or IO[bytes] + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + account=account, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Account, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Account].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(account, (IOBase, bytes)): + _content = account + else: + _content = json.dumps(account, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_accounts_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + account: _models.Account, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + account: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + account: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Required. + :type account: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + account: Union[_models.Account, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Account]: + """Updates a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param account: The parameters to provide for the created account. Is one of the following + types: Account, JSON, IO[bytes] Required. + :type account: ~azure.mgmt.cognitiveservices.models.Account or JSON or IO[bytes] + :return: An instance of LROPoller that returns Account. The Account is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + account=account, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Account, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Account].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Account]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_accounts_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Cognitive Services account from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Account"]: + """Returns all the resources of a particular type belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Account + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Account]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_accounts_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Account], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Account"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of Account + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Account]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_accounts_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Account], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ApiKeys: + """Lists the account keys for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) + + _request = build_accounts_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiKeys, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.RegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.RegenerateKeyParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ApiKeys: + """Regenerates the specified account key for the specified Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param parameters: regenerate key parameters. Is one of the following types: + RegenerateKeyParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.RegenerateKeyParameters or JSON or + IO[bytes] + :return: ApiKeys. The ApiKeys is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ApiKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiKeys] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_accounts_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiKeys, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_skus(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.AccountSkuListResult: + """List available SKUs for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: AccountSkuListResult. The AccountSkuListResult is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AccountSkuListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AccountSkuListResult] = kwargs.pop("cls", None) + + _request = build_accounts_list_skus_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccountSkuListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_usages( + self, resource_group_name: str, account_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> _models.UsageListResult: + """Get usages for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :keyword filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :paramtype filter: str + :return: UsageListResult. The UsageListResult is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.UsageListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) + + _request = build_accounts_list_usages_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UsageListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_models( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.AccountModel"]: + """List available Models for the requested Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of AccountModel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.AccountModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AccountModel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_accounts_list_models_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AccountModel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`deleted_accounts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.Account: + """Returns a Cognitive Services account specified by the parameters. + + :param location: The location name. Required. + :type location: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: Account. The Account is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Account + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Account] = kwargs.pop("cls", None) + + _request = build_deleted_accounts_get_request( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Account, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_initial( + self, location: str, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deleted_accounts_purge_request( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_purge(self, location: str, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Cognitive Services account from the resource group. + + :param location: The location name. Required. + :type location: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._purge_initial( + location=location, + resource_group_name=resource_group_name, + account_name=account_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Account"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of Account + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Account] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Account]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deleted_accounts_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Account], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connections_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update the state of specified private endpoint connection associated with the Cognitive + Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is one of the following types: + PrivateEndpointConnection, JSON, IO[bytes] Required. + :type properties: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection or JSON or + IO[bytes] + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified private endpoint connection associated with the Cognitive Services + account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Cognitive Services Account. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + private_endpoint_connection_name=private_endpoint_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionListResult: + """Gets the private endpoint connections associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: PrivateEndpointConnectionListResult. The PrivateEndpointConnectionListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateEndpointConnectionListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connections_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnectionListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> _models.Deployment: + """Gets the specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.Deployment, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(deployment, (IOBase, bytes)): + _content = deployment + else: + _content = json.dumps(deployment, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_deployments_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: _models.Deployment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.Deployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.Deployment, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update the state of specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Is one of the following types: Deployment, JSON, + IO[bytes] Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.Deployment or JSON or IO[bytes] + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + deployment=deployment, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Deployment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Deployment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Deployment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(deployment, (IOBase, bytes)): + _content = deployment + else: + _content = json.dumps(deployment, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_deployments_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: _models.PatchResourceTagsAndSku, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Required. + :type deployment: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + deployment_name: str, + deployment: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Deployment]: + """Update specified deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param deployment: The deployment properties. Is one of the following types: + PatchResourceTagsAndSku, JSON, IO[bytes] Required. + :type deployment: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Deployment. The Deployment is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + deployment=deployment, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Deployment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Deployment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Deployment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deployments_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified deployment associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.Deployment"]: + """Gets the deployments associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of Deployment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Deployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_skus( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> ItemPaged["_models.SkuResource"]: + """Lists the specified deployments skus associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: An iterator like instance of SkuResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.SkuResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SkuResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_skus_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SkuResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def pause( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> _models.Deployment: + """Pause a deployment. + + Pauses inferencing on a deployment by setting the deploymentState to 'Paused' (see + #/definitions/DeploymentProperties/properties/deploymentState). Only Standard, + DataZoneStandard, and GlobalStandard SKUs support this operation. Inference requests to the + paused deployment endpoint will receive HTTP 423 (Locked). This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_pause_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def resume( + self, resource_group_name: str, account_name: str, deployment_name: str, **kwargs: Any + ) -> _models.Deployment: + """Resume a deployment. + + Resumes inferencing on a previously paused deployment by setting the deploymentState to + 'Running' (see #/definitions/DeploymentProperties/properties/deploymentState). This operation + is idempotent and can be safely called on already running deployments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_resume_request( + resource_group_name=resource_group_name, + account_name=account_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class CommitmentPlansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`commitment_plans` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> _models.CommitmentPlan: + """Gets the specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + _request = build_commitment_plans_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Required. + :type commitment_plan: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CommitmentPlan: + """Update the state of specified commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The commitmentPlan properties. Is one of the following types: + CommitmentPlan, JSON, IO[bytes] Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or JSON or IO[bytes] + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(commitment_plan, (IOBase, bytes)): + _content = commitment_plan + else: + _content = json.dumps(commitment_plan, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_commitment_plans_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, commitment_plan_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified commitmentPlan associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + commitment_plan_name=commitment_plan_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.CommitmentPlan"]: + """Gets the commitmentPlans associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of CommitmentPlan + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlan], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_plan(self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any) -> _models.CommitmentPlan: + """Returns a Cognitive Services commitment plan specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: CommitmentPlan. The CommitmentPlan is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + + _request = build_commitment_plans_get_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(commitment_plan, (IOBase, bytes)): + _content = commitment_plan + else: + _content = json.dumps(commitment_plan, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_create_or_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.CommitmentPlan, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.CommitmentPlan, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is one of + the following types: CommitmentPlan, JSON, IO[bytes] Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.CommitmentPlan or JSON or IO[bytes] + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CommitmentPlan].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CommitmentPlan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_plan_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(commitment_plan, (IOBase, bytes)): + _content = commitment_plan + else: + _content = json.dumps(commitment_plan, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_update_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: _models.PatchResourceTagsAndSku, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Required. + :type commitment_plan: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_plan( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan: Union[_models.PatchResourceTagsAndSku, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlan]: + """Create Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan: The parameters to provide for the created commitment plan. Is one of + the following types: PatchResourceTagsAndSku, JSON, IO[bytes] Required. + :type commitment_plan: ~azure.mgmt.cognitiveservices.models.PatchResourceTagsAndSku or JSON or + IO[bytes] + :return: An instance of LROPoller that returns CommitmentPlan. The CommitmentPlan is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlan] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan=commitment_plan, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CommitmentPlan, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CommitmentPlan].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CommitmentPlan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_plan_initial( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_commitment_plans_delete_plan_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete_plan(self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a Cognitive Services commitment plan from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_plan_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_plans_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of CommitmentPlan + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_plans_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlan], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_plans_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.CommitmentPlan"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of CommitmentPlan + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlan] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlan]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_plans_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlan], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> _models.CommitmentPlanAccountAssociation: + """Gets the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :return: CommitmentPlanAccountAssociation. The CommitmentPlanAccountAssociation is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + + _request = build_commitment_plans_get_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CommitmentPlanAccountAssociation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_association_initial( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(association, (IOBase, bytes)): + _content = association + else: + _content = json.dumps(association, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_commitment_plans_create_or_update_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: _models.CommitmentPlanAccountAssociation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Required. + :type association: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_association( + self, + resource_group_name: str, + commitment_plan_name: str, + commitment_plan_association_name: str, + association: Union[_models.CommitmentPlanAccountAssociation, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CommitmentPlanAccountAssociation]: + """Create or update the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :param association: The commitmentPlan properties. Is one of the following types: + CommitmentPlanAccountAssociation, JSON, IO[bytes] Required. + :type association: ~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation or + JSON or IO[bytes] + :return: An instance of LROPoller that returns CommitmentPlanAccountAssociation. The + CommitmentPlanAccountAssociation is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CommitmentPlanAccountAssociation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_association_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + association=association, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CommitmentPlanAccountAssociation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CommitmentPlanAccountAssociation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CommitmentPlanAccountAssociation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_association_initial( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_commitment_plans_delete_association_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete_association( + self, resource_group_name: str, commitment_plan_name: str, commitment_plan_association_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the association of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :param commitment_plan_association_name: The name of the commitment plan association with the + Cognitive Services Account. Required. + :type commitment_plan_association_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_association_initial( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + commitment_plan_association_name=commitment_plan_association_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_associations( + self, resource_group_name: str, commitment_plan_name: str, **kwargs: Any + ) -> ItemPaged["_models.CommitmentPlanAccountAssociation"]: + """Gets the associations of the Cognitive Services commitment plan. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param commitment_plan_name: The name of the commitmentPlan associated with the Cognitive + Services Account. Required. + :type commitment_plan_name: str + :return: An iterator like instance of CommitmentPlanAccountAssociation + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentPlanAccountAssociation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentPlanAccountAssociation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_plans_list_associations_request( + resource_group_name=resource_group_name, + commitment_plan_name=commitment_plan_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentPlanAccountAssociation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`encryption_scopes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> _models.EncryptionScope: + """Gets the specified EncryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + _request = build_encryption_scopes_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EncryptionScope, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Required. + :type encryption_scope: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Required. + :type encryption_scope: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Required. + :type encryption_scope: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update the state of specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :param encryption_scope: The encryptionScope properties. Is one of the following types: + EncryptionScope, JSON, IO[bytes] Required. + :type encryption_scope: ~azure.mgmt.cognitiveservices.models.EncryptionScope or JSON or + IO[bytes] + :return: EncryptionScope. The EncryptionScope is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EncryptionScope] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(encryption_scope, (IOBase, bytes)): + _content = encryption_scope + else: + _content = json.dumps(encryption_scope, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_encryption_scopes_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EncryptionScope, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_encryption_scopes_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified encryptionScope associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryptionScope associated with the Cognitive + Services Account. Required. + :type encryption_scope_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.EncryptionScope"]: + """Gets the content filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of EncryptionScope + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EncryptionScope]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_encryption_scopes_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EncryptionScope], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RaiPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, rai_policy_name: str, **kwargs: Any + ) -> _models.RaiPolicy: + """Gets the specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + _request = build_rai_policies_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: _models.RaiPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_policy_name: str, + rai_policy: Union[_models.RaiPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Is one of the following types: + RaiPolicy, JSON, IO[bytes] Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy or JSON or IO[bytes] + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_policy, (IOBase, bytes)): + _content = rai_policy + else: + _content = json.dumps(rai_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_policies_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, account_name: str, rai_policy_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_policies_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, rai_policy_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified Content Filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_policy_name=rai_policy_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.RaiPolicy"]: + """Gets the content filters associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_policies_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SubscriptionRaiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`subscription_rai_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, rai_policy_name: str, **kwargs: Any) -> _models.RaiPolicy: + """Gets the specified Content Filters associated with the Subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + _request = build_subscription_rai_policy_get_request( + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + rai_policy_name: str, + rai_policy: _models.RaiPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, rai_policy_name: str, rai_policy: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, rai_policy_name: str, rai_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Required. + :type rai_policy: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, rai_policy_name: str, rai_policy: Union[_models.RaiPolicy, JSON, IO[bytes]], **kwargs: Any + ) -> _models.RaiPolicy: + """Update the state of specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :param rai_policy: Properties describing the Content Filters. Is one of the following types: + RaiPolicy, JSON, IO[bytes] Required. + :type rai_policy: ~azure.mgmt.cognitiveservices.models.RaiPolicy or JSON or IO[bytes] + :return: RaiPolicy. The RaiPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiPolicy] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_policy, (IOBase, bytes)): + _content = rai_policy + else: + _content = json.dumps(rai_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_subscription_rai_policy_create_or_update_request( + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial(self, rai_policy_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_subscription_rai_policy_delete_request( + rai_policy_name=rai_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, rai_policy_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified Content Filters associated with the subscription. + + :param rai_policy_name: The name of the RaiPolicy associated with the Cognitive Services + Account. Required. + :type rai_policy_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + rai_policy_name=rai_policy_name, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class RaiBlocklistItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_blocklist_items` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Gets the specified custom blocklist Item associated with the custom blocklist. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiBlocklistItem] = kwargs.pop("cls", None) + + _request = build_rai_blocklist_items_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklistItem, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: _models.RaiBlocklistItem, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Required. + :type rai_blocklist_item: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Required. + :type rai_blocklist_item: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Required. + :type rai_blocklist_item: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + rai_blocklist_item: Union[_models.RaiBlocklistItem, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiBlocklistItem: + """Update the state of specified blocklist item associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :param rai_blocklist_item: Properties describing the custom blocklist. Is one of the following + types: RaiBlocklistItem, JSON, IO[bytes] Required. + :type rai_blocklist_item: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem or JSON or + IO[bytes] + :return: RaiBlocklistItem. The RaiBlocklistItem is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklistItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiBlocklistItem] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist_item, (IOBase, bytes)): + _content = rai_blocklist_item + else: + _content = json.dumps(rai_blocklist_item, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklist_items_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklistItem, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_blocklist_items_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_item_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified blocklist Item associated with the custom blocklist. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_item_name: The name of the RaiBlocklist Item associated with the custom + blocklist. Required. + :type rai_blocklist_item_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + rai_blocklist_item_name=rai_blocklist_item_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> ItemPaged["_models.RaiBlocklistItem"]: + """Gets the blocklist items associated with the custom blocklist. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :return: An iterator like instance of RaiBlocklistItem + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiBlocklistItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiBlocklistItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_blocklist_items_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiBlocklistItem], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: List[_models.RaiBlocklistItemBulkRequest], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Required. + :type rai_blocklist_items: + list[~azure.mgmt.cognitiveservices.models.RaiBlocklistItemBulkRequest] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: List[JSON], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Required. + :type rai_blocklist_items: list[JSON] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Required. + :type rai_blocklist_items: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def batch_add( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items: Union[List[_models.RaiBlocklistItemBulkRequest], List[JSON], IO[bytes]], + **kwargs: Any + ) -> _models.RaiBlocklist: + """Batch operation to add blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items: Properties describing the custom blocklist items. Is one of the + following types: [RaiBlocklistItemBulkRequest], [JSON], IO[bytes] Required. + :type rai_blocklist_items: + list[~azure.mgmt.cognitiveservices.models.RaiBlocklistItemBulkRequest] or list[JSON] or + IO[bytes] + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiBlocklist] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist_items, (IOBase, bytes)): + _content = rai_blocklist_items + else: + _content = json.dumps(rai_blocklist_items, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklist_items_batch_add_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklist, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def batch_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items_names: List[str], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Batch operation to delete blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items_names: List of RAI Blocklist Items Names. Required. + :type rai_blocklist_items_names: list[str] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def batch_delete( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items_names: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Batch operation to delete blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items_names: List of RAI Blocklist Items Names. Required. + :type rai_blocklist_items_names: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def batch_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist_items_names: Union[List[str], IO[bytes]], + **kwargs: Any + ) -> None: + """Batch operation to delete blocklist items. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist_items_names: List of RAI Blocklist Items Names. Is either a [str] type or + a IO[bytes] type. Required. + :type rai_blocklist_items_names: list[str] or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist_items_names, (IOBase, bytes)): + _content = rai_blocklist_items_names + else: + _content = json.dumps(rai_blocklist_items_names, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklist_items_batch_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class RaiBlocklistsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_blocklists` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> _models.RaiBlocklist: + """Gets the specified custom blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiBlocklist] = kwargs.pop("cls", None) + + _request = build_rai_blocklists_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklist, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: _models.RaiBlocklist, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Required. + :type rai_blocklist: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Required. + :type rai_blocklist: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Required. + :type rai_blocklist: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_blocklist_name: str, + rai_blocklist: Union[_models.RaiBlocklist, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiBlocklist: + """Update the state of specified blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :param rai_blocklist: Properties describing the custom blocklist. Is one of the following + types: RaiBlocklist, JSON, IO[bytes] Required. + :type rai_blocklist: ~azure.mgmt.cognitiveservices.models.RaiBlocklist or JSON or IO[bytes] + :return: RaiBlocklist. The RaiBlocklist is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiBlocklist + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiBlocklist] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_blocklist, (IOBase, bytes)): + _content = rai_blocklist + else: + _content = json.dumps(rai_blocklist, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_blocklists_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiBlocklist, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_blocklists_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, rai_blocklist_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified custom blocklist associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_blocklist_name: The name of the RaiBlocklist associated with the Cognitive Services + Account. Required. + :type rai_blocklist_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_blocklist_name=rai_blocklist_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.RaiBlocklist"]: + """Gets the custom blocklists associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiBlocklist + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiBlocklist] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiBlocklist]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_blocklists_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiBlocklist], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RaiTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_topics` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, rai_topic_name: str, **kwargs: Any) -> _models.RaiTopic: + """Gets the specified custom topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiTopic] = kwargs.pop("cls", None) + + _request = build_rai_topics_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: _models.RaiTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Required. + :type rai_topic: ~azure.mgmt.cognitiveservices.models.RaiTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Required. + :type rai_topic: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Required. + :type rai_topic: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_topic_name: str, + rai_topic: Union[_models.RaiTopic, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiTopic: + """Create the rai topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :param rai_topic: Properties describing the rai topic. Is one of the following types: RaiTopic, + JSON, IO[bytes] Required. + :type rai_topic: ~azure.mgmt.cognitiveservices.models.RaiTopic or JSON or IO[bytes] + :return: RaiTopic. The RaiTopic is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiTopic] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_topic, (IOBase, bytes)): + _content = rai_topic + else: + _content = json.dumps(rai_topic, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_topics_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiTopic, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, account_name: str, rai_topic_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_topics_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, rai_topic_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified custom topic associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_topic_name: The name of the Rai Topic associated with the Cognitive Services + Account. Required. + :type rai_topic_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_topic_name=rai_topic_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.RaiTopic"]: + """Gets the custom topics associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiTopic + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiTopic]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_topics_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiTopic], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RaiToolLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_tool_labels` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, rai_tool_connection_name: str, **kwargs: Any + ) -> _models.RaiToolLabel: + """Gets the specified RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiToolLabel] = kwargs.pop("cls", None) + + _request = build_rai_tool_labels_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiToolLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: _models.RaiToolLabel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Required. + :type rai_tool_label: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Required. + :type rai_tool_label: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Required. + :type rai_tool_label: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + rai_tool_connection_name: str, + rai_tool_label: Union[_models.RaiToolLabel, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiToolLabel: + """Creates the RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :param rai_tool_label: Properties describing the RAI Tool Label. Is one of the following types: + RaiToolLabel, JSON, IO[bytes] Required. + :type rai_tool_label: ~azure.mgmt.cognitiveservices.models.RaiToolLabel or JSON or IO[bytes] + :return: RaiToolLabel. The RaiToolLabel is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiToolLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiToolLabel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rai_tool_label, (IOBase, bytes)): + _content = rai_tool_label + else: + _content = json.dumps(rai_tool_label, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_tool_labels_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiToolLabel, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, account_name: str, rai_tool_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_tool_labels_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, rai_tool_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified RAI Tool Label associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param rai_tool_connection_name: The name of the Rai Tool Label. Required. + :type rai_tool_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + rai_tool_connection_name=rai_tool_connection_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.RaiToolLabel"]: + """Lists all RAI Tool Labels associated with the Azure OpenAI account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of RaiToolLabel + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiToolLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiToolLabel]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_tool_labels_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiToolLabel], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RaiContentFiltersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_content_filters` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, filter_name: str, **kwargs: Any) -> _models.RaiContentFilter: + """Get Content Filters by Name. + + :param location: The name of the Azure region. Required. + :type location: str + :param filter_name: The name of the RAI Content Filter. Required. + :type filter_name: str + :return: RaiContentFilter. The RaiContentFilter is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiContentFilter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiContentFilter] = kwargs.pop("cls", None) + + _request = build_rai_content_filters_get_request( + location=location, + filter_name=filter_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiContentFilter, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> ItemPaged["_models.RaiContentFilter"]: + """List Content Filters types. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of RaiContentFilter + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiContentFilter] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiContentFilter]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_content_filters_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiContentFilter], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NetworkSecurityPerimeterConfigurationsOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`network_security_perimeter_configurations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, nsp_configuration_name: str, **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets the specified NSP configurations for an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param nsp_configuration_name: The name of the NSP Configuration. Required. + :type nsp_configuration_name: str + :return: NetworkSecurityPerimeterConfiguration. The NetworkSecurityPerimeterConfiguration is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + nsp_configuration_name=nsp_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of NetworkSecurityPerimeterConfiguration + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_network_security_perimeter_configurations_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NetworkSecurityPerimeterConfiguration], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _reconcile_initial( + self, resource_group_name: str, account_name: str, nsp_configuration_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_network_security_perimeter_configurations_reconcile_request( + resource_group_name=resource_group_name, + account_name=account_name, + nsp_configuration_name=nsp_configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_reconcile( + self, resource_group_name: str, account_name: str, nsp_configuration_name: str, **kwargs: Any + ) -> LROPoller[_models.NetworkSecurityPerimeterConfiguration]: + """Reconcile the NSP configuration for an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param nsp_configuration_name: The name of the NSP Configuration. Required. + :type nsp_configuration_name: str + :return: An instance of LROPoller that returns NetworkSecurityPerimeterConfiguration. The + NetworkSecurityPerimeterConfiguration is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reconcile_initial( + resource_group_name=resource_group_name, + account_name=account_name, + nsp_configuration_name=nsp_configuration_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.NetworkSecurityPerimeterConfiguration, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.NetworkSecurityPerimeterConfiguration].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.NetworkSecurityPerimeterConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class DefenderForAISettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`defender_for_ai_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, defender_for_ai_setting_name: str, **kwargs: Any + ) -> _models.DefenderForAISetting: + """Gets the specified Defender for AI setting by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DefenderForAISetting] = kwargs.pop("cls", None) + + _request = build_defender_for_ai_settings_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + defender_for_ai_setting_name=defender_for_ai_setting_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DefenderForAISetting, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: _models.DefenderForAISetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: Union[_models.DefenderForAISetting, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Creates or Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Is one of + the following types: DefenderForAISetting, JSON, IO[bytes] Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting or + JSON or IO[bytes] + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForAISetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(defender_for_ai_settings, (IOBase, bytes)): + _content = defender_for_ai_settings + else: + _content = json.dumps(defender_for_ai_settings, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_defender_for_ai_settings_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + defender_for_ai_setting_name=defender_for_ai_setting_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DefenderForAISetting, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: _models.DefenderForAISetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Required. + :type defender_for_ai_settings: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + defender_for_ai_setting_name: str, + defender_for_ai_settings: Union[_models.DefenderForAISetting, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.DefenderForAISetting: + """Updates the specified Defender for AI setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param defender_for_ai_setting_name: The name of the defender for AI setting. Required. + :type defender_for_ai_setting_name: str + :param defender_for_ai_settings: Properties describing the Defender for AI setting. Is one of + the following types: DefenderForAISetting, JSON, IO[bytes] Required. + :type defender_for_ai_settings: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting or + JSON or IO[bytes] + :return: DefenderForAISetting. The DefenderForAISetting is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DefenderForAISetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForAISetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(defender_for_ai_settings, (IOBase, bytes)): + _content = defender_for_ai_settings + else: + _content = json.dumps(defender_for_ai_settings, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_defender_for_ai_settings_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + defender_for_ai_setting_name=defender_for_ai_setting_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DefenderForAISetting, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.DefenderForAISetting"]: + """Lists the Defender for AI settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of DefenderForAISetting + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.DefenderForAISetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DefenderForAISetting]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_defender_for_ai_settings_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DefenderForAISetting], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`projects` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any) -> _models.Project: + """Returns a Cognitive Services project specified by the parameters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :return: Project. The Project is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Project + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + + _request = build_projects_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Project, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(project, (IOBase, bytes)): + _content = project + else: + _content = json.dumps(project, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_projects_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create Cognitive Services Account's Project. Project is a sub-resource of an account which give + AI developer it's individual container to work on. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Is one of the following + types: Project, JSON, IO[bytes] Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project or JSON or IO[bytes] + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + project=project, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Project, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Project].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Project]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(project, (IOBase, bytes)): + _content = project + else: + _content = json.dumps(project, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_projects_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Required. + :type project: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + project: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Updates a Cognitive Services Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param project: The parameters to provide for the created project. Is one of the following + types: Project, JSON, IO[bytes] Required. + :type project: ~azure.mgmt.cognitiveservices.models.Project or JSON or IO[bytes] + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Project] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + project=project, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Project, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Project].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Project]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_projects_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a Cognitive Services project from the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.Project"]: + """Returns all the projects in a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of Project + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Project]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_projects_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Project], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProjectConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`project_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, project_name: str, connection_name: str, **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Lists Cognitive Services project connection by name. + + Lists Cognitive Services project connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + _request = build_project_connections_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[_models.ConnectionPropertiesV2BasicResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionPropertiesV2BasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services project connection under the specified project. + + Create or update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Is one of the + following types: ConnectionPropertiesV2BasicResource, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource or + JSON or IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_project_connections_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[_models.ConnectionUpdateContent] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionUpdateContent, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services project connection under the specified project. + + Update Cognitive Services project connection under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Is one of the following types: + ConnectionUpdateContent, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent or JSON or + IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_project_connections_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, project_name: str, connection_name: str, **kwargs: Any + ) -> None: + """Delete Cognitive Services project connection by name. + + Delete Cognitive Services project connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_project_connections_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + project_name: str, + *, + target: Optional[str] = None, + category: Optional[str] = None, + include_all: bool = False, + **kwargs: Any + ) -> ItemPaged["_models.ConnectionPropertiesV2BasicResource"]: + """Lists all the available Cognitive Services project connections under the specified project. + + Lists all the available Cognitive Services project connections under the specified project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :keyword target: Target of the connection. Default value is None. + :paramtype target: str + :keyword category: Category of the connection. Default value is None. + :paramtype category: str + :keyword include_all: query parameter that indicates if get connection call should return both + connections and datastores. Default value is False. + :paramtype include_all: bool + :return: An iterator like instance of ConnectionPropertiesV2BasicResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ConnectionPropertiesV2BasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_project_connections_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + target=target, + category=category, + include_all=include_all, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ConnectionPropertiesV2BasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProjectCapabilityHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`project_capability_hosts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, project_name: str, capability_host_name: str, **kwargs: Any + ) -> _models.ProjectCapabilityHost: + """Get project capabilityHost. + + Get project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: ProjectCapabilityHost. The ProjectCapabilityHost is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProjectCapabilityHost] = kwargs.pop("cls", None) + + _request = build_project_capability_hosts_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProjectCapabilityHost, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: Union[_models.ProjectCapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(capability_host, (IOBase, bytes)): + _content = capability_host + else: + _content = json.dumps(capability_host, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_project_capability_hosts_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: _models.ProjectCapabilityHost, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ProjectCapabilityHost. The ProjectCapabilityHost + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ProjectCapabilityHost. The ProjectCapabilityHost + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ProjectCapabilityHost. The ProjectCapabilityHost + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + capability_host_name: str, + capability_host: Union[_models.ProjectCapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ProjectCapabilityHost]: + """Create or update project capabilityHost. + + Create or update project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Is one of the following types: + ProjectCapabilityHost, JSON, IO[bytes] Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ProjectCapabilityHost. The ProjectCapabilityHost + is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ProjectCapabilityHost] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + capability_host=capability_host, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ProjectCapabilityHost, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ProjectCapabilityHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ProjectCapabilityHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, project_name: str, capability_host_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_project_capability_hosts_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, project_name: str, capability_host_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete project capabilityHost. + + Delete project capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + capability_host_name=capability_host_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, project_name: str, **kwargs: Any + ) -> ItemPaged["_models.ProjectCapabilityHost"]: + """List capabilityHost. + + List capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :return: An iterator like instance of ProjectCapabilityHost + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ProjectCapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProjectCapabilityHost]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_project_capability_hosts_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProjectCapabilityHost], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class QuotaTiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`quota_tiers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, default: str, **kwargs: Any) -> _models.QuotaTier: + """Gets the Quota Tier for a subscription. + + Gets the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.QuotaTier] = kwargs.pop("cls", None) + + _request = build_quota_tiers_get_request( + default=default, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaTier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, default: str, tier: _models.QuotaTier, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, default: str, tier: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, default: str, tier: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, default: str, tier: Union[_models.QuotaTier, JSON, IO[bytes]], **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Is one of the following + types: QuotaTier, JSON, IO[bytes] Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier or JSON or IO[bytes] + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaTier] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(tier, (IOBase, bytes)): + _content = tier + else: + _content = json.dumps(tier, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_tiers_create_or_update_request( + default=default, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaTier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, default: str, tier: _models.QuotaTier, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, default: str, tier: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, default: str, tier: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Required. + :type tier: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update(self, default: str, tier: Union[_models.QuotaTier, JSON, IO[bytes]], **kwargs: Any) -> _models.QuotaTier: + """Updates the Quota Tier resource for a subscription. The only properties that can be updated are + "tierUpgradePolicy". + + Update the Quota Tier information for the given subscription. QuotaTiers is a subscription wide + resource type. It holds current tier information. + + :param default: Default parameter. Leave the value as default. Required. + :type default: str + :param tier: The parameters to provide for the quota tier resource. Is one of the following + types: QuotaTier, JSON, IO[bytes] Required. + :type tier: ~azure.mgmt.cognitiveservices.models.QuotaTier or JSON or IO[bytes] + :return: QuotaTier. The QuotaTier is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.QuotaTier + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaTier] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(tier, (IOBase, bytes)): + _content = tier + else: + _content = json.dumps(tier, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_tiers_update_request( + default=default, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaTier, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.QuotaTier"]: + """Returns all the resources of a particular type belonging to a subscription. + + :return: An iterator like instance of QuotaTier + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.QuotaTier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.QuotaTier]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_quota_tiers_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.QuotaTier], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AgentApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`agent_applications` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> _models.AgentApplication: + """Gets an Agent Application by name. + + Gets an Agent Application by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: AgentApplication. The AgentApplication is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AgentApplication + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AgentApplication] = kwargs.pop("cls", None) + + _request = build_agent_applications_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentApplication, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: Union[_models.AgentApplication, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_applications_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: _models.AgentApplication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentApplication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + name: str, + body: Union[_models.AgentApplication, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AgentApplication]: + """Creates or updates an Agent Application (asynchronous). + + Creates or updates an Agent Application (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :param body: Agent Application definition object. Is one of the following types: + AgentApplication, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentApplication or JSON or IO[bytes] + :return: An instance of LROPoller that returns AgentApplication. The AgentApplication is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentApplication] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AgentApplication, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AgentApplication].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AgentApplication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_applications_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete Agent Application. + + Delete Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + project_name: str, + *, + count: int = 30, + skip: Optional[int] = None, + skip_token: Optional[str] = None, + names: Optional[List[str]] = None, + search_text: Optional[str] = None, + order_by: Optional[str] = None, + order_by_asc: bool = False, + **kwargs: Any + ) -> ItemPaged["_models.AgentApplication"]: + """Lists Agent Applications in the project. + + Lists Agent Applications in the project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :keyword count: Number of agent applications to be retrieved in a page of results. Default + value is 30. + :paramtype count: int + :keyword skip: Number of agent applications to skip. Default value is None. + :paramtype skip: int + :keyword skip_token: Continuation token for pagination. Default value is None. + :paramtype skip_token: str + :keyword names: Names of agent applications to retrieve. Default value is None. + :paramtype names: list[str] + :keyword search_text: Search text for filtering agent applications. Default value is None. + :paramtype search_text: str + :keyword order_by: Field to order by. Default value is None. + :paramtype order_by: str + :keyword order_by_asc: Whether to order in ascending order. Default value is False. + :paramtype order_by_asc: bool + :return: An iterator like instance of AgentApplication + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.AgentApplication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentApplication]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_agent_applications_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + count=count, + skip=skip, + skip_token=skip_token, + names=names, + search_text=search_text, + order_by=order_by, + order_by_asc=order_by_asc, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentApplication], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_agents( + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> _models.AgentReferenceResourceArmPaginatedResult: + """Lists agents for an Agent Application. + + Lists agents for an Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: AgentReferenceResourceArmPaginatedResult. The AgentReferenceResourceArmPaginatedResult + is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AgentReferenceResourceArmPaginatedResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AgentReferenceResourceArmPaginatedResult] = kwargs.pop("cls", None) + + _request = build_agent_applications_list_agents_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentReferenceResourceArmPaginatedResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def enable( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> None: + """Enables an Agent Application. + + Enables an Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_applications_enable_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def disable( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, project_name: str, name: str, **kwargs: Any + ) -> None: + """Disables an Agent Application. + + Disables an Agent Application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param name: Name for the Agent Application. Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_applications_disable_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ComputesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`computes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, compute_name: str, **kwargs: Any) -> _models.Compute: + """Gets the specified compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :return: Compute. The Compute is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.Compute + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Compute] = kwargs.pop("cls", None) + + _request = build_computes_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Compute, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: Union[_models.Compute, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_computes_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: _models.Compute, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Required. + :type resource: ~azure.mgmt.cognitiveservices.models.Compute + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Required. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Required. + :type resource: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + resource: Union[_models.Compute, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Creates or updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param resource: The compute properties. Is one of the following types: Compute, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.cognitiveservices.models.Compute or JSON or IO[bytes] + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Compute] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Compute, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Compute].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Compute]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: Union[_models.ComputePatch, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_computes_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: _models.ComputePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Required. + :type properties: ~azure.mgmt.cognitiveservices.models.ComputePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Required. + :type properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + compute_name: str, + properties: Union[_models.ComputePatch, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Compute]: + """Updates a compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :param properties: The compute properties. Is one of the following types: ComputePatch, JSON, + IO[bytes] Required. + :type properties: ~azure.mgmt.cognitiveservices.models.ComputePatch or JSON or IO[bytes] + :return: An instance of LROPoller that returns Compute. The Compute is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Compute] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + properties=properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Compute, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Compute].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Compute]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, compute_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_computes_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, compute_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified compute associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param compute_name: The name of the compute associated with the Cognitive Services Account. + Required. + :type compute_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + compute_name=compute_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.Compute"]: + """Gets the computes associated with the Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of Compute + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Compute] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Compute]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_computes_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Compute], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a Cognitive Services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_link_resources_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class TestRaiExternalSafetyProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`test_rai_external_safety_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: _models.RaiExternalSafetyProviderSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + safety_provider_name: str, + safety_provider: Union[_models.RaiExternalSafetyProviderSchema, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.RaiExternalSafetyProviderSchema: + """Test the rai safety provider associated with the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Is one of the + following types: RaiExternalSafetyProviderSchema, JSON, IO[bytes] Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + JSON or IO[bytes] + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.RaiExternalSafetyProviderSchema] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(safety_provider, (IOBase, bytes)): + _content = safety_provider + else: + _content = json.dumps(safety_provider, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_test_rai_external_safety_provider_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProviderSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ManagedNetworkProvisionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`managed_network_provisions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _provision_managed_network_initial( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ManagedNetworkProvisionOptions, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_managed_network_provisions_provision_managed_network_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[_models.ManagedNetworkProvisionOptions] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Default + value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionOptions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Default + value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Default + value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_provision_managed_network( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ManagedNetworkProvisionOptions, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkProvisionStatus]: + """Provisions the managed network of a cognitive services account. + + Provisions the managed network of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param body: Managed Network Provisioning Options for a cognitive services account. Is one of + the following types: ManagedNetworkProvisionOptions, JSON, IO[bytes] Default value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionOptions or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ManagedNetworkProvisionStatus. The + ManagedNetworkProvisionStatus is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkProvisionStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.ManagedNetworkProvisionStatus] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._provision_managed_network_initial( + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedNetworkProvisionStatus, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedNetworkProvisionStatus].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedNetworkProvisionStatus]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class RaiExternalSafetyProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_external_safety_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, safety_provider_name: str, **kwargs: Any) -> _models.RaiExternalSafetyProviderSchema: + """Gets the specified external safety provider associated with the Subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :return: RaiExternalSafetyProviderSchema. The RaiExternalSafetyProviderSchema is compatible + with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RaiExternalSafetyProviderSchema] = kwargs.pop("cls", None) + + _request = build_rai_external_safety_provider_get_request( + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProviderSchema, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update( + self, + safety_provider_name: str, + safety_provider: _models.RaiExternalSafetyProviderSchema, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, safety_provider_name: str, safety_provider: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + safety_provider_name: str, + safety_provider: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Required. + :type safety_provider: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + safety_provider_name: str, + safety_provider: Union[_models.RaiExternalSafetyProviderSchema, JSON, IO[bytes]], + **kwargs: Any + ) -> Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]: + """Create the rai safety provider associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :param safety_provider: Properties describing the rai external safety provider. Is one of the + following types: RaiExternalSafetyProviderSchema, JSON, IO[bytes] Required. + :type safety_provider: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + JSON or IO[bytes] + :return: RaiExternalSafetyProviderSchema or RaiExternalSafetyProvider. The + RaiExternalSafetyProviderSchema is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema or + ~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProvider + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Union[_models.RaiExternalSafetyProviderSchema, _models.RaiExternalSafetyProvider]] = kwargs.pop( + "cls", None + ) + + content_type = content_type or "application/json" + _content = None + if isinstance(safety_provider, (IOBase, bytes)): + _content = safety_provider + else: + _content = json.dumps(safety_provider, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rai_external_safety_provider_create_or_update_request( + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProviderSchema, response.json()) + + if response.status_code == 201: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RaiExternalSafetyProvider, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial(self, safety_provider_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rai_external_safety_provider_delete_request( + safety_provider_name=safety_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, safety_provider_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes the specified custom topic associated with the subscription. + + :param safety_provider_name: The name of the Rai External Safety Provider associated with the + Cognitive Services Account. Required. + :type safety_provider_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + safety_provider_name=safety_provider_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class RaiExternalSafetyProvidersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`rai_external_safety_providers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.RaiExternalSafetyProviderSchema"]: + """Gets the safety providers associated with the subscription. + + :return: An iterator like instance of RaiExternalSafetyProviderSchema + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.RaiExternalSafetyProviderSchema] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RaiExternalSafetyProviderSchema]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rai_external_safety_providers_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RaiExternalSafetyProviderSchema], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AccountConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`account_connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, connection_name: str, **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Lists Cognitive Services account connection by name. + + Lists Cognitive Services account connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + _request = build_account_connections_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[_models.ConnectionPropertiesV2BasicResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Default value + is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionPropertiesV2BasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Create or update Cognitive Services account connection under the specified account. + + Create or update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: The object for creating or updating a new account connection. Is one of the + following types: ConnectionPropertiesV2BasicResource, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource or + JSON or IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_account_connections_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[_models.ConnectionUpdateContent] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Default value is None. + :type connection: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + connection_name: str, + connection: Optional[Union[_models.ConnectionUpdateContent, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ConnectionPropertiesV2BasicResource: + """Update Cognitive Services account connection under the specified account. + + Update Cognitive Services account connection under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :param connection: Parameters for account connection update. Is one of the following types: + ConnectionUpdateContent, JSON, IO[bytes] Default value is None. + :type connection: ~azure.mgmt.cognitiveservices.models.ConnectionUpdateContent or JSON or + IO[bytes] + :return: ConnectionPropertiesV2BasicResource. The ConnectionPropertiesV2BasicResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if connection else None + cls: ClsType[_models.ConnectionPropertiesV2BasicResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if connection else None + _content = None + if isinstance(connection, (IOBase, bytes)): + _content = connection + else: + if connection is not None: + _content = json.dumps(connection, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_account_connections_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ConnectionPropertiesV2BasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, connection_name: str, **kwargs: Any + ) -> None: + """Delete Cognitive Services account connection by name. + + Delete Cognitive Services account connection by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param connection_name: Friendly name of the connection. Required. + :type connection_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_account_connections_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + connection_name=connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + *, + target: Optional[str] = None, + category: Optional[str] = None, + include_all: bool = False, + **kwargs: Any + ) -> ItemPaged["_models.ConnectionPropertiesV2BasicResource"]: + """Lists all the available Cognitive Services account connections under the specified account. + + Lists all the available Cognitive Services account connections under the specified account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :keyword target: Target of the connection. Default value is None. + :paramtype target: str + :keyword category: Category of the connection. Default value is None. + :paramtype category: str + :keyword include_all: query parameter that indicates if get connection call should return both + connections and datastores. Default value is False. + :paramtype include_all: bool + :return: An iterator like instance of ConnectionPropertiesV2BasicResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ConnectionPropertiesV2BasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ConnectionPropertiesV2BasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_account_connections_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + target=target, + category=category, + include_all=include_all, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ConnectionPropertiesV2BasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AccountCapabilityHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`account_capability_hosts` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, capability_host_name: str, **kwargs: Any + ) -> _models.CapabilityHost: + """Get account capabilityHost. + + Get account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: CapabilityHost. The CapabilityHost is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CapabilityHost + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CapabilityHost] = kwargs.pop("cls", None) + + _request = build_account_capability_hosts_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CapabilityHost, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: Union[_models.CapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(capability_host, (IOBase, bytes)): + _content = capability_host + else: + _content = json.dumps(capability_host, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_account_capability_hosts_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: _models.CapabilityHost, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.CapabilityHost + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CapabilityHost. The CapabilityHost is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CapabilityHost. The CapabilityHost is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Required. + :type capability_host: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CapabilityHost. The CapabilityHost is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + capability_host_name: str, + capability_host: Union[_models.CapabilityHost, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CapabilityHost]: + """Create or update account capabilityHost. + + Create or update account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :param capability_host: CapabilityHost definition. Is one of the following types: + CapabilityHost, JSON, IO[bytes] Required. + :type capability_host: ~azure.mgmt.cognitiveservices.models.CapabilityHost or JSON or IO[bytes] + :return: An instance of LROPoller that returns CapabilityHost. The CapabilityHost is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CapabilityHost] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + capability_host=capability_host, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CapabilityHost, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CapabilityHost].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CapabilityHost]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, capability_host_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_account_capability_hosts_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, capability_host_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete account capabilityHost. + + Delete account capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param capability_host_name: The name of the capability host associated with the Cognitive + Services Resource. Required. + :type capability_host_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + capability_host_name=capability_host_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> ItemPaged["_models.CapabilityHost"]: + """List capabilityHost. + + List capabilityHost. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of CapabilityHost + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CapabilityHost] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CapabilityHost]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_account_capability_hosts_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CapabilityHost], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OutboundRuleOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`outbound_rule` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, managed_network_name: str, rule_name: str, **kwargs: Any + ) -> _models.OutboundRuleBasicResource: + """The GET API for retrieving a single outbound rule of the managed network associated with the + cognitive services account. + + The GET API for retrieving a single outbound rule of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :return: OutboundRuleBasicResource. The OutboundRuleBasicResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OutboundRuleBasicResource] = kwargs.pop("cls", None) + + _request = build_outbound_rule_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OutboundRuleBasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: Union[_models.OutboundRuleBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_outbound_rule_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: _models.OutboundRuleBasicResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Required. + :type body: ~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + rule_name: str, + body: Union[_models.OutboundRuleBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleBasicResource]: + """The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + The PUT API for creating or updating a single outbound rule of the managed network associated + with the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :param body: Is one of the following types: OutboundRuleBasicResource, JSON, IO[bytes] + Required. + :type body: ~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource or JSON or IO[bytes] + :return: An instance of LROPoller that returns OutboundRuleBasicResource. The + OutboundRuleBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OutboundRuleBasicResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OutboundRuleBasicResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OutboundRuleBasicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OutboundRuleBasicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, account_name: str, managed_network_name: str, rule_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_outbound_rule_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, managed_network_name: str, rule_name: str, **kwargs: Any + ) -> LROPoller[None]: + """The DELETE API for deleting a single outbound rule of the managed network associated with the + cognitive services account. + + The DELETE API for deleting a single outbound rule of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param rule_name: Name of the cognitive services account managed network outbound rule. + Required. + :type rule_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + rule_name=rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, managed_network_name: str, **kwargs: Any + ) -> ItemPaged["_models.OutboundRuleBasicResource"]: + """The GET API for retrieving the list of outbound rules of the managed network associated with + the cognitive services account. + + The GET API for retrieving the list of outbound rules of the managed network associated with + the cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :return: An iterator like instance of OutboundRuleBasicResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.OutboundRuleBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OutboundRuleBasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_outbound_rule_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OutboundRuleBasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedNetworkSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`managed_network_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, managed_network_name: str, **kwargs: Any + ) -> _models.ManagedNetworkSettingsPropertiesBasicResource: + """Get API for managed network settings of a cognitive services account. + + Get API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :return: ManagedNetworkSettingsPropertiesBasicResource. The + ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ManagedNetworkSettingsPropertiesBasicResource] = kwargs.pop("cls", None) + + _request = build_managed_network_settings_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ManagedNetworkSettingsPropertiesBasicResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _put_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_managed_network_settings_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: _models.ManagedNetworkSettingsPropertiesBasicResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_put( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """PUT API for managed network settings of a cognitive services account. + + PUT API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Is one of the following types: + ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagedNetworkSettingsPropertiesBasicResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._put_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedNetworkSettingsPropertiesBasicResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _patch_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if body else None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_managed_network_settings_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[_models.ManagedNetworkSettingsPropertiesBasicResource] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Default value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_patch( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Optional[Union[_models.ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]: + """Patch API for managed network settings of a cognitive services account. + + Patch API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Is one of the following types: + ManagedNetworkSettingsPropertiesBasicResource, JSON, IO[bytes] Default value is None. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource + or JSON or IO[bytes] + :return: An instance of LROPoller that returns ManagedNetworkSettingsPropertiesBasicResource. + The ManagedNetworkSettingsPropertiesBasicResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if body else None + cls: ClsType[_models.ManagedNetworkSettingsPropertiesBasicResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._patch_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.ManagedNetworkSettingsPropertiesBasicResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ManagedNetworkSettingsPropertiesBasicResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> ItemPaged["_models.ManagedNetworkSettingsPropertiesBasicResource"]: + """List API for managed network settings of a cognitive services account. + + List API for managed network settings of a cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :return: An iterator like instance of ManagedNetworkSettingsPropertiesBasicResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsPropertiesBasicResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedNetworkSettingsPropertiesBasicResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_network_settings_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedNetworkSettingsPropertiesBasicResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OutboundRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`outbound_rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _post_initial( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_outbound_rules_post_request( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: _models.ManagedNetworkSettingsBasicResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsBasicResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_post( + self, + resource_group_name: str, + account_name: str, + managed_network_name: str, + body: Union[_models.ManagedNetworkSettingsBasicResource, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OutboundRuleListResult]: + """The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + The POST API for updating the outbound rules of the managed network associated with the + cognitive services account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param managed_network_name: Name of the managedNetwork associated with the cognitive services + account. Only 'default' is supported. Required. + :type managed_network_name: str + :param body: The Managed Network Settings object of the account. Is one of the following types: + ManagedNetworkSettingsBasicResource, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.ManagedNetworkSettingsBasicResource or JSON or + IO[bytes] + :return: An instance of LROPoller that returns OutboundRuleListResult. The + OutboundRuleListResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.OutboundRuleListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OutboundRuleListResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._post_initial( + resource_group_name=resource_group_name, + account_name=account_name, + managed_network_name=managed_network_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.OutboundRuleListResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OutboundRuleListResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OutboundRuleListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class AgentDeploymentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`agent_deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> _models.AgentDeployment: + """Gets an Agent Deployment by name. + + Gets an Agent Deployment by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: AgentDeployment. The AgentDeployment is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.AgentDeployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AgentDeployment] = kwargs.pop("cls", None) + + _request = build_agent_deployments_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentDeployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: Union[_models.AgentDeployment, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_deployments_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["x-ms-async-operation-timeout"] = self._deserialize( + "str", response.headers.get("x-ms-async-operation-timeout") + ) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: _models.AgentDeployment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentDeployment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + body: Union[_models.AgentDeployment, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AgentDeployment]: + """Creates or updates an Agent Deployment (asynchronous). + + Creates or updates an Agent Deployment (asynchronous). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :param body: Agent Deployment definition object. Is one of the following types: + AgentDeployment, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.cognitiveservices.models.AgentDeployment or JSON or IO[bytes] + :return: An instance of LROPoller that returns AgentDeployment. The AgentDeployment is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentDeployment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AgentDeployment, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AgentDeployment].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AgentDeployment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_agent_deployments_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete Agent Deployment. + + Delete Agent Deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + *, + count: int = 30, + skip_token: Optional[str] = None, + names: Optional[List[str]] = None, + order_by: Optional[str] = None, + order_by_asc: bool = False, + **kwargs: Any + ) -> ItemPaged["_models.AgentDeployment"]: + """Lists Agent Deployments in the application. + + Lists Agent Deployments in the application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :keyword count: Number of agent deployments to be retrieved in a page of results. Default value + is 30. + :paramtype count: int + :keyword skip_token: Continuation token for pagination. Default value is None. + :paramtype skip_token: str + :keyword names: Names of agent deployments to retrieve. Default value is None. + :paramtype names: list[str] + :keyword order_by: Field to order by. Default value is None. + :paramtype order_by: str + :keyword order_by_asc: Whether to order in ascending order. Default value is False. + :paramtype order_by_asc: bool + :return: An iterator like instance of AgentDeployment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.AgentDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentDeployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_agent_deployments_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + subscription_id=self._config.subscription_id, + count=count, + skip_token=skip_token, + names=names, + order_by=order_by, + order_by_asc=order_by_asc, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def start( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: + """Starts an Agent Deployment. + + Starts an Agent Deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_deployments_start_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + project_name: str, + app_name: str, + deployment_name: str, + **kwargs: Any + ) -> None: + """Stops an Agent Deployment. + + Stops an Agent Deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of Cognitive Services account. Required. + :type account_name: str + :param project_name: The name of Cognitive Services account's project. Required. + :type project_name: str + :param app_name: The name of the application associated with the Cognitive Services Account. + Required. + :type app_name: str + :param deployment_name: The name of the deployment associated with the Cognitive Services + Account. Required. + :type deployment_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_agent_deployments_stop_request( + resource_group_name=resource_group_name, + account_name=account_name, + project_name=project_name, + app_name=app_name, + deployment_name=deployment_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ResourceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`resource_skus` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.ResourceSku"]: + """Gets the list of Microsoft.CognitiveServices SKUs available for your Subscription. + + :return: An iterator like instance of ResourceSku + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceSku]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_resource_skus_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceSku], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`usages` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, *, filter: Optional[str] = None, **kwargs: Any) -> ItemPaged["_models.Usage"]: + """Get usages for the requested subscription. + + :param location: The location name. Required. + :type location: str + :keyword filter: An OData filter expression that describes a subset of usages to return. The + supported parameter is name.value (name of the metric, can have an or of multiple names). + Default value is None. + :paramtype filter: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_usages_list_request( + location=location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CommitmentTiersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`commitment_tiers` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> ItemPaged["_models.CommitmentTier"]: + """List Commitment Tiers. + + :param location: The location name. Required. + :type location: str + :return: An iterator like instance of CommitmentTier + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.CommitmentTier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CommitmentTier]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_commitment_tiers_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CommitmentTier], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ModelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`models` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, location: str, **kwargs: Any) -> ItemPaged["_models.Model"]: + """List Models. + + :param location: The location name. Required. + :type location: str + :return: An iterator like instance of Model + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Model] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Model]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_models_list_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Model], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class LocationBasedModelCapacitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`location_based_model_capacities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: CognitiveServicesManagementClientConfiguration = ( + input_args.pop(0) if input_args else kwargs.pop("config") + ) + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, location: str, *, model_format: str, model_name: str, model_version: str, **kwargs: Any + ) -> ItemPaged["_models.ModelCapacityListResultValueItem"]: + """List Location Based ModelCapacities. + + :param location: The location name. Required. + :type location: str + :keyword model_format: The format of the Model. Required. + :paramtype model_format: str + :keyword model_name: The name of the Model. Required. + :paramtype model_name: str + :keyword model_version: The version of the Model. Required. + :paramtype model_version: str + :return: An iterator like instance of ModelCapacityListResultValueItem + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ModelCapacityListResultValueItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ModelCapacityListResultValueItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_location_based_model_capacities_list_request( + location=location, + subscription_id=self._config.subscription_id, + model_format=model_format, + model_name=model_name, + model_version=model_version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ModelCapacityListResultValueItem], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ModelCapacitiesOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.cognitiveservices.CognitiveServicesManagementClient`'s + :attr:`model_capacities` attribute. + """ def __init__(self, *args, **kwargs) -> None: input_args = list(args) @@ -78,18 +24406,26 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: - """Lists all the available Cognitive Services account operations. + def list( + self, *, model_format: str, model_name: str, model_version: str, **kwargs: Any + ) -> ItemPaged["_models.ModelCapacityListResultValueItem"]: + """List ModelCapacities. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.Operation] + :keyword model_format: The format of the Model. Required. + :paramtype model_format: str + :keyword model_name: The name of the Model. Required. + :paramtype model_name: str + :keyword model_version: The version of the Model. Required. + :paramtype model_version: str + :return: An iterator like instance of ModelCapacityListResultValueItem + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.cognitiveservices.models.ModelCapacityListResultValueItem] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ModelCapacityListResultValueItem]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -102,12 +24438,21 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_model_capacities_list_request( + subscription_id=self._config.subscription_id, + model_format=model_format, + model_name=model_name, + model_version=model_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -122,16 +24467,24 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ModelCapacityListResultValueItem], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -144,9 +24497,428 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) + + +class _CognitiveServicesManagementClientOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], CognitiveServicesManagementClientConfiguration] +): + + @overload + def check_sku_availability( + self, + location: str, + parameters: _models.CheckSkuAvailabilityParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_sku_availability( + self, location: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_sku_availability( + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_sku_availability( + self, location: str, parameters: Union[_models.CheckSkuAvailabilityParameter, JSON, IO[bytes]], **kwargs: Any + ) -> _models.SkuAvailabilityListResult: + """Check available SKUs. + + :param location: The location name. Required. + :type location: str + :param parameters: The request body. Is one of the following types: + CheckSkuAvailabilityParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckSkuAvailabilityParameter or JSON or + IO[bytes] + :return: SkuAvailabilityListResult. The SkuAvailabilityListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.SkuAvailabilityListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SkuAvailabilityListResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cognitive_services_management_check_sku_availability_request( + location=location, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SkuAvailabilityListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_domain_availability( + self, + parameters: _models.CheckDomainAvailabilityParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_domain_availability( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_domain_availability( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_domain_availability( + self, parameters: Union[_models.CheckDomainAvailabilityParameter, JSON, IO[bytes]], **kwargs: Any + ) -> _models.DomainAvailability: + """Check whether a domain is available. + + :param parameters: The request body. Is one of the following types: + CheckDomainAvailabilityParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CheckDomainAvailabilityParameter or JSON + or IO[bytes] + :return: DomainAvailability. The DomainAvailability is compatible with MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.DomainAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DomainAvailability] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cognitive_services_management_check_domain_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DomainAvailability, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def calculate_model_capacity( + self, + parameters: _models.CalculateModelCapacityParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def calculate_model_capacity( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def calculate_model_capacity( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def calculate_model_capacity( + self, parameters: Union[_models.CalculateModelCapacityParameter, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CalculateModelCapacityResult: + """Model capacity calculator. + + :param parameters: The request body. Is one of the following types: + CalculateModelCapacityParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityParameter or JSON + or IO[bytes] + :return: CalculateModelCapacityResult. The CalculateModelCapacityResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.cognitiveservices.models.CalculateModelCapacityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CalculateModelCapacityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cognitive_services_management_calculate_model_capacity_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CalculateModelCapacityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/pyproject.toml b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/pyproject.toml index 090765007225..b343a16ff5c2 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/pyproject.toml +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/pyproject.toml @@ -1,19 +1,23 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + [build-system] -requires = [ - "setuptools>=77.0.3", - "wheel", -] +requires = ["setuptools>=77.0.3", "wheel"] build-backend = "setuptools.build_meta" [project] name = "azure-mgmt-cognitiveservices" authors = [ - { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, ] description = "Microsoft Azure Cognitiveservices Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", @@ -24,32 +28,23 @@ classifiers = [ "Programming Language :: Python :: 3.13", ] requires-python = ">=3.9" -keywords = [ - "azure", - "azure sdk", -] +keywords = ["azure", "azure sdk"] + dependencies = [ - "msrest>=0.7.1", + "isodate>=0.6.1", "azure-mgmt-core>=1.6.0", "typing-extensions>=4.6.0", ] dynamic = [ - "version", - "readme", +"version", "readme" ] [project.urls] repository = "https://github.com/Azure/azure-sdk-for-python" -[tool.setuptools.dynamic.version] -attr = "azure.mgmt.cognitiveservices._version.VERSION" - -[tool.setuptools.dynamic.readme] -file = [ - "README.md", - "CHANGELOG.md", -] -content-type = "text/markdown" +[tool.setuptools.dynamic] +version = {attr = "azure.mgmt.cognitiveservices._version.VERSION"} +readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} [tool.setuptools.packages.find] exclude = [ @@ -63,9 +58,7 @@ exclude = [ ] [tool.setuptools.package-data] -pytyped = [ - "py.typed", -] +pytyped = ["py.typed"] [tool.azure-sdk-build] breaking = false diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/disable_test_cli_mgmt_cognitiveservices.py b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/disable_test_cli_mgmt_cognitiveservices.py index c43cdd7c2719..e28f34589bde 100644 --- a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/disable_test_cli_mgmt_cognitiveservices.py +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tests/disable_test_cli_mgmt_cognitiveservices.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 # ------------------------------------------------------------------------- diff --git a/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tsp-location.yaml b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tsp-location.yaml new file mode 100644 index 000000000000..7f808a5d25bf --- /dev/null +++ b/sdk/cognitiveservices/azure-mgmt-cognitiveservices/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cognitiveservices/CognitiveServices.Management +commit: +repo: +additionalDirectories: