diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 92d6682453e1..6b7348e9adca 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -1,6 +1,7 @@ # requirements leveraged by ci tools setuptools==44.1.0; python_version == '2.7' setuptools==45.1.0; python_version >= '3.5' +virtualenv==20.0.24 wheel==0.34.2 Jinja2==2.11.1 packaging==20.4 @@ -32,4 +33,3 @@ pytest-cov==2.8.1 ./tools/azure-sdk-tools - diff --git a/eng/pipelines/templates/steps/build-test.yml b/eng/pipelines/templates/steps/build-test.yml index bc8451d96b5e..10aad24725d2 100644 --- a/eng/pipelines/templates/steps/build-test.yml +++ b/eng/pipelines/templates/steps/build-test.yml @@ -26,27 +26,27 @@ steps: - template: /eng/common/pipelines/templates/steps/verify-agent-os.yml - script: | - python -m pip install pip == 20.1 - pip install -r eng/ci_tools.txt - pip --version + python -m pip install -r eng/ci_tools.txt + mkdir $(Build.SourcesDirectory)/env + python -m virtualenv $(Build.SourcesDirectory)/env displayName: 'Prep Environment' - ${{ parameters.BeforeTestSteps }} - - task: PythonScript@0 - displayName: 'Run Tests' - inputs: - scriptPath: 'scripts/devops_tasks/setup_execute_tests.py' - arguments: >- - "${{ parameters.BuildTargetingString }}" - ${{ parameters.AdditionalTestArgs }} - ${{ parameters.CoverageArg }} - --mark_arg="${{ parameters.TestMarkArgument }}" - --service="${{ parameters.ServiceDirectory }}" - --toxenv="${{ parameters.ToxTestEnv }}" - --injected-packages="${{ parameters.InjectedPackages }}" - ${{ parameters.ToxEnvParallel }} + - pwsh: | + $env:Path = "$(Build.SourcesDirectory)/env;" + $env:Path + python -m pip install pip==20.1 + python -m pip install -r eng/ci_tools.txt + python -m pip --version + + $env:PYTHON_HOME = "" + $env:VIRTUAL_ENV = "$(Build.SourcesDirectory)/env" + + Write-Host 'python ./scripts/devops_tasks/setup_execute_tests.py "${{ parameters.BuildTargetingString }}" ${{ parameters.AdditionalTestArgs }} ${{ parameters.CoverageArg }} --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" --toxenv="${{ parameters.ToxTestEnv }}" --injected-packages="${{ parameters.InjectedPackages }}" ${{ parameters.ToxEnvParallel }}"' + python ./scripts/devops_tasks/setup_execute_tests.py "${{ parameters.BuildTargetingString }}" ${{ parameters.AdditionalTestArgs }} ${{ parameters.CoverageArg }} --mark_arg="${{ parameters.TestMarkArgument }}" --service="${{ parameters.ServiceDirectory }}" --toxenv="${{ parameters.ToxTestEnv }}" --injected-packages="${{ parameters.InjectedPackages }}" ${{ parameters.ToxEnvParallel }} + env: ${{ parameters.EnvVars }} + displayName: 'Run Tests' - ${{ parameters.AfterTestSteps }} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/CHANGELOG.md b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/CHANGELOG.md index bb340557b7f5..6101c87517a0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/CHANGELOG.md +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/CHANGELOG.md @@ -1,5 +1,35 @@ # Release History +## 3.0.0 (2020-06-22) + +*Training 3.3* + +**Features** + + - Model ImageUrlCreateBatch has a new parameter metadata + - Model ImageIdCreateBatch has a new parameter metadata + - Model Prediction has a new parameter tag_type + - Model ImageFileCreateBatch has a new parameter metadata + - Model Image has a new parameter metadata + - Added operation get_images + - Added operation update_image_metadata + - Added operation get_artifact + - Added operation get_image_count + +**Breaking changes** + + - Operation import_project has a new signature + - Operation publish_iteration has a new signature + - Operation create_images_from_files has a new signature + - Operation create_images_from_urls has a new signature + - Operation create_images_from_predictions has a new signature + +*Prediction 3.1* + +**Features** + + - Model Prediction has a new parameter tag_type + ## 2.0.0 (2020-05-14) **Features** @@ -21,7 +51,7 @@ **Breaking changes** -- Credentials are now longer a simple string, but a `msrest.authentication.ApiKeyCredentials` instance instead +- Credentials are now longer a simple string, but a `msrest.authentication.ApiKeyCredentials` instance instead **General Breaking changes** diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py index 17c83361819f..da2695822d5b 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_configuration.py @@ -33,7 +33,7 @@ def __init__( raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = '{Endpoint}/customvision/v3.0/prediction' + base_url = '{Endpoint}/customvision/v3.1/prediction' super(CustomVisionPredictionClientConfiguration, self).__init__(base_url) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py index abfb4a51227f..74d0c50ec5cf 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/_custom_vision_prediction_client.py @@ -37,7 +37,7 @@ def __init__( super(CustomVisionPredictionClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '3.0' + self.api_version = '3.1' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py index d654981d00aa..3ec9e2927bba 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/__init__.py @@ -23,6 +23,7 @@ from ._models import Prediction from ._custom_vision_prediction_client_enums import ( CustomVisionErrorCodes, + TagType, ) __all__ = [ @@ -32,4 +33,5 @@ 'ImageUrl', 'Prediction', 'CustomVisionErrorCodes', + 'TagType', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_custom_vision_prediction_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_custom_vision_prediction_client_enums.py index cf908ce921ee..2282b02c977c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_custom_vision_prediction_client_enums.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_custom_vision_prediction_client_enums.py @@ -26,10 +26,13 @@ class CustomVisionErrorCodes(str, Enum): bad_request_project_unknown_classification = "BadRequestProjectUnknownClassification" bad_request_project_unsupported_domain_type_change = "BadRequestProjectUnsupportedDomainTypeChange" bad_request_project_unsupported_export_platform = "BadRequestProjectUnsupportedExportPlatform" + bad_request_project_image_preprocessing_settings = "BadRequestProjectImagePreprocessingSettings" + bad_request_project_duplicated = "BadRequestProjectDuplicated" bad_request_iteration_name = "BadRequestIterationName" bad_request_iteration_name_not_unique = "BadRequestIterationNameNotUnique" bad_request_iteration_description = "BadRequestIterationDescription" bad_request_iteration_is_not_trained = "BadRequestIterationIsNotTrained" + bad_request_iteration_validation_failed = "BadRequestIterationValidationFailed" bad_request_workspace_cannot_be_modified = "BadRequestWorkspaceCannotBeModified" bad_request_workspace_not_deletable = "BadRequestWorkspaceNotDeletable" bad_request_tag_name = "BadRequestTagName" @@ -37,14 +40,17 @@ class CustomVisionErrorCodes(str, Enum): bad_request_tag_description = "BadRequestTagDescription" bad_request_tag_type = "BadRequestTagType" bad_request_multiple_negative_tag = "BadRequestMultipleNegativeTag" + bad_request_multiple_general_product_tag = "BadRequestMultipleGeneralProductTag" bad_request_image_tags = "BadRequestImageTags" bad_request_image_regions = "BadRequestImageRegions" bad_request_negative_and_regular_tag_on_same_image = "BadRequestNegativeAndRegularTagOnSameImage" + bad_request_unsupported_domain = "BadRequestUnsupportedDomain" bad_request_required_param_is_null = "BadRequestRequiredParamIsNull" bad_request_iteration_is_published = "BadRequestIterationIsPublished" bad_request_invalid_publish_name = "BadRequestInvalidPublishName" bad_request_invalid_publish_target = "BadRequestInvalidPublishTarget" bad_request_unpublish_failed = "BadRequestUnpublishFailed" + bad_request_iteration_not_published = "BadRequestIterationNotPublished" bad_request_subscription_api = "BadRequestSubscriptionApi" bad_request_exceed_project_limit = "BadRequestExceedProjectLimit" bad_request_exceed_iteration_per_project_limit = "BadRequestExceedIterationPerProjectLimit" @@ -58,6 +64,7 @@ class CustomVisionErrorCodes(str, Enum): bad_request_image_url = "BadRequestImageUrl" bad_request_image_format = "BadRequestImageFormat" bad_request_image_size_bytes = "BadRequestImageSizeBytes" + bad_request_image_dimensions = "BadRequestImageDimensions" bad_request_image_exceeded_count = "BadRequestImageExceededCount" bad_request_training_not_needed = "BadRequestTrainingNotNeeded" bad_request_training_not_needed_but_training_pipeline_updated = "BadRequestTrainingNotNeededButTrainingPipelineUpdated" @@ -80,6 +87,13 @@ class CustomVisionErrorCodes(str, Enum): bad_request_prediction_results_exceeded_count = "BadRequestPredictionResultsExceededCount" bad_request_prediction_invalid_application_name = "BadRequestPredictionInvalidApplicationName" bad_request_prediction_invalid_query_parameters = "BadRequestPredictionInvalidQueryParameters" + bad_request_invalid_import_token = "BadRequestInvalidImportToken" + bad_request_export_while_training = "BadRequestExportWhileTraining" + bad_request_image_metadata_key = "BadRequestImageMetadataKey" + bad_request_image_metadata_value = "BadRequestImageMetadataValue" + bad_request_operation_not_supported = "BadRequestOperationNotSupported" + bad_request_invalid_artifact_uri = "BadRequestInvalidArtifactUri" + bad_request_customer_managed_key_revoked = "BadRequestCustomerManagedKeyRevoked" bad_request_invalid = "BadRequestInvalid" unsupported_media_type = "UnsupportedMediaType" forbidden = "Forbidden" @@ -105,10 +119,13 @@ class CustomVisionErrorCodes(str, Enum): conflict = "Conflict" conflict_invalid = "ConflictInvalid" error_unknown = "ErrorUnknown" + error_iteration_copy_failed = "ErrorIterationCopyFailed" + error_prepare_performance_migration_failed = "ErrorPreparePerformanceMigrationFailed" error_project_invalid_workspace = "ErrorProjectInvalidWorkspace" error_project_invalid_pipeline_configuration = "ErrorProjectInvalidPipelineConfiguration" error_project_invalid_domain = "ErrorProjectInvalidDomain" error_project_training_request_failed = "ErrorProjectTrainingRequestFailed" + error_project_import_request_failed = "ErrorProjectImportRequestFailed" error_project_export_request_failed = "ErrorProjectExportRequestFailed" error_featurization_service_unavailable = "ErrorFeaturizationServiceUnavailable" error_featurization_queue_timeout = "ErrorFeaturizationQueueTimeout" @@ -125,4 +142,12 @@ class CustomVisionErrorCodes(str, Enum): error_prediction = "ErrorPrediction" error_prediction_storage = "ErrorPredictionStorage" error_region_proposal = "ErrorRegionProposal" + error_unknown_base_model = "ErrorUnknownBaseModel" error_invalid = "ErrorInvalid" + + +class TagType(str, Enum): + + regular = "Regular" + negative = "Negative" + general_product = "GeneralProduct" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py index 6c4860c8748c..b245eba70734 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models.py @@ -62,25 +62,29 @@ class CustomVisionError(Model): 'BadRequestProjectUnknownDomain', 'BadRequestProjectUnknownClassification', 'BadRequestProjectUnsupportedDomainTypeChange', - 'BadRequestProjectUnsupportedExportPlatform', 'BadRequestIterationName', + 'BadRequestProjectUnsupportedExportPlatform', + 'BadRequestProjectImagePreprocessingSettings', + 'BadRequestProjectDuplicated', 'BadRequestIterationName', 'BadRequestIterationNameNotUnique', 'BadRequestIterationDescription', - 'BadRequestIterationIsNotTrained', 'BadRequestWorkspaceCannotBeModified', - 'BadRequestWorkspaceNotDeletable', 'BadRequestTagName', - 'BadRequestTagNameNotUnique', 'BadRequestTagDescription', - 'BadRequestTagType', 'BadRequestMultipleNegativeTag', + 'BadRequestIterationIsNotTrained', 'BadRequestIterationValidationFailed', + 'BadRequestWorkspaceCannotBeModified', 'BadRequestWorkspaceNotDeletable', + 'BadRequestTagName', 'BadRequestTagNameNotUnique', + 'BadRequestTagDescription', 'BadRequestTagType', + 'BadRequestMultipleNegativeTag', 'BadRequestMultipleGeneralProductTag', 'BadRequestImageTags', 'BadRequestImageRegions', 'BadRequestNegativeAndRegularTagOnSameImage', - 'BadRequestRequiredParamIsNull', 'BadRequestIterationIsPublished', - 'BadRequestInvalidPublishName', 'BadRequestInvalidPublishTarget', - 'BadRequestUnpublishFailed', 'BadRequestSubscriptionApi', + 'BadRequestUnsupportedDomain', 'BadRequestRequiredParamIsNull', + 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + 'BadRequestInvalidPublishTarget', 'BadRequestUnpublishFailed', + 'BadRequestIterationNotPublished', 'BadRequestSubscriptionApi', 'BadRequestExceedProjectLimit', 'BadRequestExceedIterationPerProjectLimit', 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', - 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', - 'BadRequestTrainingNotNeeded', + 'BadRequestImageSizeBytes', 'BadRequestImageDimensions', + 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', 'BadRequestClassificationTrainingValidationFailed', @@ -98,7 +102,11 @@ class CustomVisionError(Model): 'BadRequestPredictionTagsExceededCount', 'BadRequestPredictionResultsExceededCount', 'BadRequestPredictionInvalidApplicationName', - 'BadRequestPredictionInvalidQueryParameters', 'BadRequestInvalid', + 'BadRequestPredictionInvalidQueryParameters', + 'BadRequestInvalidImportToken', 'BadRequestExportWhileTraining', + 'BadRequestImageMetadataKey', 'BadRequestImageMetadataValue', + 'BadRequestOperationNotSupported', 'BadRequestInvalidArtifactUri', + 'BadRequestCustomerManagedKeyRevoked', 'BadRequestInvalid', 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', 'ForbiddenUserResource', 'ForbiddenUserSignupDisabled', 'ForbiddenUserSignupAllowanceExceeded', 'ForbiddenUserDoesNotExist', @@ -107,19 +115,20 @@ class CustomVisionError(Model): 'NotFoundProject', 'NotFoundProjectDefaultIteration', 'NotFoundIteration', 'NotFoundIterationPerformance', 'NotFoundTag', 'NotFoundImage', 'NotFoundDomain', 'NotFoundApimSubscription', 'NotFoundInvalid', - 'Conflict', 'ConflictInvalid', 'ErrorUnknown', - 'ErrorProjectInvalidWorkspace', + 'Conflict', 'ConflictInvalid', 'ErrorUnknown', 'ErrorIterationCopyFailed', + 'ErrorPreparePerformanceMigrationFailed', 'ErrorProjectInvalidWorkspace', 'ErrorProjectInvalidPipelineConfiguration', 'ErrorProjectInvalidDomain', - 'ErrorProjectTrainingRequestFailed', 'ErrorProjectExportRequestFailed', - 'ErrorFeaturizationServiceUnavailable', 'ErrorFeaturizationQueueTimeout', - 'ErrorFeaturizationInvalidFeaturizer', + 'ErrorProjectTrainingRequestFailed', 'ErrorProjectImportRequestFailed', + 'ErrorProjectExportRequestFailed', 'ErrorFeaturizationServiceUnavailable', + 'ErrorFeaturizationQueueTimeout', 'ErrorFeaturizationInvalidFeaturizer', 'ErrorFeaturizationAugmentationUnavailable', 'ErrorFeaturizationUnrecognizedJob', 'ErrorFeaturizationAugmentationError', 'ErrorExporterInvalidPlatform', 'ErrorExporterInvalidFeaturizer', 'ErrorExporterInvalidClassifier', 'ErrorPredictionServiceUnavailable', 'ErrorPredictionModelNotFound', 'ErrorPredictionModelNotCached', 'ErrorPrediction', - 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorInvalid' + 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorUnknownBaseModel', + 'ErrorInvalid' :type code: str or ~azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorCodes :param message: Required. A message explaining the error reported by the @@ -236,6 +245,10 @@ class Prediction(Model): :ivar bounding_box: Bounding box of the prediction. :vartype bounding_box: ~azure.cognitiveservices.vision.customvision.prediction.models.BoundingBox + :ivar tag_type: Type of the predicted tag. Possible values include: + 'Regular', 'Negative', 'GeneralProduct' + :vartype tag_type: str or + ~azure.cognitiveservices.vision.customvision.prediction.models.TagType """ _validation = { @@ -243,6 +256,7 @@ class Prediction(Model): 'tag_id': {'readonly': True}, 'tag_name': {'readonly': True}, 'bounding_box': {'readonly': True}, + 'tag_type': {'readonly': True}, } _attribute_map = { @@ -250,6 +264,7 @@ class Prediction(Model): 'tag_id': {'key': 'tagId', 'type': 'str'}, 'tag_name': {'key': 'tagName', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, + 'tag_type': {'key': 'tagType', 'type': 'str'}, } def __init__(self, **kwargs): @@ -258,3 +273,4 @@ def __init__(self, **kwargs): self.tag_id = None self.tag_name = None self.bounding_box = None + self.tag_type = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py index a7ef53998a0a..b9313dc78ab4 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/models/_models_py3.py @@ -62,25 +62,29 @@ class CustomVisionError(Model): 'BadRequestProjectUnknownDomain', 'BadRequestProjectUnknownClassification', 'BadRequestProjectUnsupportedDomainTypeChange', - 'BadRequestProjectUnsupportedExportPlatform', 'BadRequestIterationName', + 'BadRequestProjectUnsupportedExportPlatform', + 'BadRequestProjectImagePreprocessingSettings', + 'BadRequestProjectDuplicated', 'BadRequestIterationName', 'BadRequestIterationNameNotUnique', 'BadRequestIterationDescription', - 'BadRequestIterationIsNotTrained', 'BadRequestWorkspaceCannotBeModified', - 'BadRequestWorkspaceNotDeletable', 'BadRequestTagName', - 'BadRequestTagNameNotUnique', 'BadRequestTagDescription', - 'BadRequestTagType', 'BadRequestMultipleNegativeTag', + 'BadRequestIterationIsNotTrained', 'BadRequestIterationValidationFailed', + 'BadRequestWorkspaceCannotBeModified', 'BadRequestWorkspaceNotDeletable', + 'BadRequestTagName', 'BadRequestTagNameNotUnique', + 'BadRequestTagDescription', 'BadRequestTagType', + 'BadRequestMultipleNegativeTag', 'BadRequestMultipleGeneralProductTag', 'BadRequestImageTags', 'BadRequestImageRegions', 'BadRequestNegativeAndRegularTagOnSameImage', - 'BadRequestRequiredParamIsNull', 'BadRequestIterationIsPublished', - 'BadRequestInvalidPublishName', 'BadRequestInvalidPublishTarget', - 'BadRequestUnpublishFailed', 'BadRequestSubscriptionApi', + 'BadRequestUnsupportedDomain', 'BadRequestRequiredParamIsNull', + 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + 'BadRequestInvalidPublishTarget', 'BadRequestUnpublishFailed', + 'BadRequestIterationNotPublished', 'BadRequestSubscriptionApi', 'BadRequestExceedProjectLimit', 'BadRequestExceedIterationPerProjectLimit', 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', - 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', - 'BadRequestTrainingNotNeeded', + 'BadRequestImageSizeBytes', 'BadRequestImageDimensions', + 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', 'BadRequestClassificationTrainingValidationFailed', @@ -98,7 +102,11 @@ class CustomVisionError(Model): 'BadRequestPredictionTagsExceededCount', 'BadRequestPredictionResultsExceededCount', 'BadRequestPredictionInvalidApplicationName', - 'BadRequestPredictionInvalidQueryParameters', 'BadRequestInvalid', + 'BadRequestPredictionInvalidQueryParameters', + 'BadRequestInvalidImportToken', 'BadRequestExportWhileTraining', + 'BadRequestImageMetadataKey', 'BadRequestImageMetadataValue', + 'BadRequestOperationNotSupported', 'BadRequestInvalidArtifactUri', + 'BadRequestCustomerManagedKeyRevoked', 'BadRequestInvalid', 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', 'ForbiddenUserResource', 'ForbiddenUserSignupDisabled', 'ForbiddenUserSignupAllowanceExceeded', 'ForbiddenUserDoesNotExist', @@ -107,19 +115,20 @@ class CustomVisionError(Model): 'NotFoundProject', 'NotFoundProjectDefaultIteration', 'NotFoundIteration', 'NotFoundIterationPerformance', 'NotFoundTag', 'NotFoundImage', 'NotFoundDomain', 'NotFoundApimSubscription', 'NotFoundInvalid', - 'Conflict', 'ConflictInvalid', 'ErrorUnknown', - 'ErrorProjectInvalidWorkspace', + 'Conflict', 'ConflictInvalid', 'ErrorUnknown', 'ErrorIterationCopyFailed', + 'ErrorPreparePerformanceMigrationFailed', 'ErrorProjectInvalidWorkspace', 'ErrorProjectInvalidPipelineConfiguration', 'ErrorProjectInvalidDomain', - 'ErrorProjectTrainingRequestFailed', 'ErrorProjectExportRequestFailed', - 'ErrorFeaturizationServiceUnavailable', 'ErrorFeaturizationQueueTimeout', - 'ErrorFeaturizationInvalidFeaturizer', + 'ErrorProjectTrainingRequestFailed', 'ErrorProjectImportRequestFailed', + 'ErrorProjectExportRequestFailed', 'ErrorFeaturizationServiceUnavailable', + 'ErrorFeaturizationQueueTimeout', 'ErrorFeaturizationInvalidFeaturizer', 'ErrorFeaturizationAugmentationUnavailable', 'ErrorFeaturizationUnrecognizedJob', 'ErrorFeaturizationAugmentationError', 'ErrorExporterInvalidPlatform', 'ErrorExporterInvalidFeaturizer', 'ErrorExporterInvalidClassifier', 'ErrorPredictionServiceUnavailable', 'ErrorPredictionModelNotFound', 'ErrorPredictionModelNotCached', 'ErrorPrediction', - 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorInvalid' + 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorUnknownBaseModel', + 'ErrorInvalid' :type code: str or ~azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorCodes :param message: Required. A message explaining the error reported by the @@ -236,6 +245,10 @@ class Prediction(Model): :ivar bounding_box: Bounding box of the prediction. :vartype bounding_box: ~azure.cognitiveservices.vision.customvision.prediction.models.BoundingBox + :ivar tag_type: Type of the predicted tag. Possible values include: + 'Regular', 'Negative', 'GeneralProduct' + :vartype tag_type: str or + ~azure.cognitiveservices.vision.customvision.prediction.models.TagType """ _validation = { @@ -243,6 +256,7 @@ class Prediction(Model): 'tag_id': {'readonly': True}, 'tag_name': {'readonly': True}, 'bounding_box': {'readonly': True}, + 'tag_type': {'readonly': True}, } _attribute_map = { @@ -250,6 +264,7 @@ class Prediction(Model): 'tag_id': {'key': 'tagId', 'type': 'str'}, 'tag_name': {'key': 'tagName', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, + 'tag_type': {'key': 'tagType', 'type': 'str'}, } def __init__(self, **kwargs) -> None: @@ -258,3 +273,4 @@ def __init__(self, **kwargs) -> None: self.tag_id = None self.tag_name = None self.bounding_box = None + self.tag_type = None diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py index 49127e2fb22c..9ee845e0360a 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/prediction/operations/_custom_vision_prediction_client_operations.py @@ -15,17 +15,18 @@ class CustomVisionPredictionClientOperationsMixin(object): - def classify_image_url( - self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): - """Classify an image url and saves the result. + def classify_image( + self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config): + """Classify an image and saves the result. :param project_id: The project id. :type project_id: str :param published_name: Specifies the name of the model to evaluate against. :type published_name: str - :param url: Url of the image. - :type url: str + :param image_data: Binary image data. Supported formats are JPEG, GIF, + PNG, and BMP. Supports images up to 4MB. + :type image_data: Generator :param application: Optional. Specifies the name of application using the endpoint. :type application: str @@ -41,10 +42,8 @@ def classify_image_url( :raises: :class:`CustomVisionErrorException` """ - image_url = models.ImageUrl(url=url) - # Construct URL - url = self.classify_image_url.metadata['url'] + url = self.classify_image.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -60,15 +59,17 @@ def classify_image_url( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) - # Construct body - body_content = self._serialize.body(image_url, 'ImageUrl') + # Construct form data + form_data_content = { + 'imageData': image_data, + } # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) + request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: @@ -83,11 +84,11 @@ def classify_image_url( return client_raw_response return deserialized - classify_image_url.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/url'} + classify_image.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/image'} - def classify_image( + def classify_image_with_no_store( self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config): - """Classify an image and saves the result. + """Classify an image without saving the result. :param project_id: The project id. :type project_id: str @@ -113,7 +114,7 @@ def classify_image( :class:`CustomVisionErrorException` """ # Construct URL - url = self.classify_image.metadata['url'] + url = self.classify_image_with_no_store.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -154,11 +155,11 @@ def classify_image( return client_raw_response return deserialized - classify_image.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/image'} + classify_image_with_no_store.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/image/nostore'} - def classify_image_url_with_no_store( + def classify_image_url( self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): - """Classify an image url without saving the result. + """Classify an image url and saves the result. :param project_id: The project id. :type project_id: str @@ -185,7 +186,7 @@ def classify_image_url_with_no_store( image_url = models.ImageUrl(url=url) # Construct URL - url = self.classify_image_url_with_no_store.metadata['url'] + url = self.classify_image_url.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -224,20 +225,19 @@ def classify_image_url_with_no_store( return client_raw_response return deserialized - classify_image_url_with_no_store.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/url/nostore'} + classify_image_url.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/url'} - def classify_image_with_no_store( - self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config): - """Classify an image without saving the result. + def classify_image_url_with_no_store( + self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): + """Classify an image url without saving the result. :param project_id: The project id. :type project_id: str :param published_name: Specifies the name of the model to evaluate against. :type published_name: str - :param image_data: Binary image data. Supported formats are JPEG, GIF, - PNG, and BMP. Supports images up to 0MB. - :type image_data: Generator + :param url: Url of the image. + :type url: str :param application: Optional. Specifies the name of application using the endpoint. :type application: str @@ -253,8 +253,10 @@ def classify_image_with_no_store( :raises: :class:`CustomVisionErrorException` """ + image_url = models.ImageUrl(url=url) + # Construct URL - url = self.classify_image_with_no_store.metadata['url'] + url = self.classify_image_url_with_no_store.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -270,17 +272,15 @@ def classify_image_with_no_store( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'multipart/form-data' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) - # Construct form data - form_data_content = { - 'imageData': image_data, - } + # Construct body + body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content) + request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: @@ -295,19 +295,20 @@ def classify_image_with_no_store( return client_raw_response return deserialized - classify_image_with_no_store.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/image/nostore'} + classify_image_url_with_no_store.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/url/nostore'} - def detect_image_url( - self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): - """Detect objects in an image url and saves the result. + def detect_image( + self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config): + """Detect objects in an image and saves the result. :param project_id: The project id. :type project_id: str :param published_name: Specifies the name of the model to evaluate against. :type published_name: str - :param url: Url of the image. - :type url: str + :param image_data: Binary image data. Supported formats are JPEG, GIF, + PNG, and BMP. Supports images up to 4MB. + :type image_data: Generator :param application: Optional. Specifies the name of application using the endpoint. :type application: str @@ -323,10 +324,8 @@ def detect_image_url( :raises: :class:`CustomVisionErrorException` """ - image_url = models.ImageUrl(url=url) - # Construct URL - url = self.detect_image_url.metadata['url'] + url = self.detect_image.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -342,15 +341,17 @@ def detect_image_url( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) - # Construct body - body_content = self._serialize.body(image_url, 'ImageUrl') + # Construct form data + form_data_content = { + 'imageData': image_data, + } # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) + request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: @@ -365,11 +366,11 @@ def detect_image_url( return client_raw_response return deserialized - detect_image_url.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/url'} + detect_image.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/image'} - def detect_image( + def detect_image_with_no_store( self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config): - """Detect objects in an image and saves the result. + """Detect objects in an image without saving the result. :param project_id: The project id. :type project_id: str @@ -395,7 +396,7 @@ def detect_image( :class:`CustomVisionErrorException` """ # Construct URL - url = self.detect_image.metadata['url'] + url = self.detect_image_with_no_store.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -436,11 +437,11 @@ def detect_image( return client_raw_response return deserialized - detect_image.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/image'} + detect_image_with_no_store.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/image/nostore'} - def detect_image_url_with_no_store( + def detect_image_url( self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): - """Detect objects in an image url without saving the result. + """Detect objects in an image url and saves the result. :param project_id: The project id. :type project_id: str @@ -467,7 +468,7 @@ def detect_image_url_with_no_store( image_url = models.ImageUrl(url=url) # Construct URL - url = self.detect_image_url_with_no_store.metadata['url'] + url = self.detect_image_url.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -506,20 +507,19 @@ def detect_image_url_with_no_store( return client_raw_response return deserialized - detect_image_url_with_no_store.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/url/nostore'} + detect_image_url.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/url'} - def detect_image_with_no_store( - self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config): - """Detect objects in an image without saving the result. + def detect_image_url_with_no_store( + self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config): + """Detect objects in an image url without saving the result. :param project_id: The project id. :type project_id: str :param published_name: Specifies the name of the model to evaluate against. :type published_name: str - :param image_data: Binary image data. Supported formats are JPEG, GIF, - PNG, and BMP. Supports images up to 0MB. - :type image_data: Generator + :param url: Url of the image. + :type url: str :param application: Optional. Specifies the name of application using the endpoint. :type application: str @@ -535,8 +535,10 @@ def detect_image_with_no_store( :raises: :class:`CustomVisionErrorException` """ + image_url = models.ImageUrl(url=url) + # Construct URL - url = self.detect_image_with_no_store.metadata['url'] + url = self.detect_image_url_with_no_store.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'projectId': self._serialize.url("project_id", project_id, 'str'), @@ -552,17 +554,15 @@ def detect_image_with_no_store( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'multipart/form-data' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) - # Construct form data - form_data_content = { - 'imageData': image_data, - } + # Construct body + body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content) + request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: @@ -577,4 +577,4 @@ def detect_image_with_no_store( return client_raw_response return deserialized - detect_image_with_no_store.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/image/nostore'} + detect_image_url_with_no_store.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/url/nostore'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_configuration.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_configuration.py index 312e310eeab6..3ce58988527c 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_configuration.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_configuration.py @@ -33,7 +33,7 @@ def __init__( raise ValueError("Parameter 'endpoint' must not be None.") if credentials is None: raise ValueError("Parameter 'credentials' must not be None.") - base_url = '{Endpoint}/customvision/v3.2/training' + base_url = '{Endpoint}/customvision/v3.3/training' super(CustomVisionTrainingClientConfiguration, self).__init__(base_url) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_custom_vision_training_client.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_custom_vision_training_client.py index a995accbf5c8..31f266dcda99 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_custom_vision_training_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/_custom_vision_training_client.py @@ -14,6 +14,7 @@ from ._configuration import CustomVisionTrainingClientConfiguration from .operations import CustomVisionTrainingClientOperationsMixin +from msrest.exceptions import HttpOperationError from . import models @@ -37,7 +38,7 @@ def __init__( super(CustomVisionTrainingClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '3.2' + self.api_version = '3.3' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/__init__.py index 987b397f62fc..df2405aed22b 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/__init__.py @@ -21,6 +21,8 @@ from ._models_py3 import ImageFileCreateEntry from ._models_py3 import ImageIdCreateBatch from ._models_py3 import ImageIdCreateEntry + from ._models_py3 import ImageMetadataUpdateEntry + from ._models_py3 import ImageMetadataUpdateSummary from ._models_py3 import ImagePerformance from ._models_py3 import ImagePrediction from ._models_py3 import ImageProcessingSettings @@ -69,6 +71,8 @@ from ._models import ImageFileCreateEntry from ._models import ImageIdCreateBatch from ._models import ImageIdCreateEntry + from ._models import ImageMetadataUpdateEntry + from ._models import ImageMetadataUpdateSummary from ._models import ImagePerformance from ._models import ImagePrediction from ._models import ImageProcessingSettings @@ -113,6 +117,7 @@ ExportPlatform, ExportStatus, ImageCreateStatus, + ImageMetadataUpdateStatus, OrderBy, ProjectStatus, SortBy, @@ -132,6 +137,8 @@ 'ImageFileCreateEntry', 'ImageIdCreateBatch', 'ImageIdCreateEntry', + 'ImageMetadataUpdateEntry', + 'ImageMetadataUpdateSummary', 'ImagePerformance', 'ImagePrediction', 'ImageProcessingSettings', @@ -174,10 +181,11 @@ 'ExportStatus', 'ExportFlavor', 'ImageCreateStatus', + 'ImageMetadataUpdateStatus', + 'TagType', 'Classifier', 'TrainingType', 'OrderBy', 'ProjectStatus', 'SortBy', - 'TagType', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_custom_vision_training_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_custom_vision_training_client_enums.py index 8a23ddb1ad59..9aca554c0359 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_custom_vision_training_client_enums.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_custom_vision_training_client_enums.py @@ -40,9 +40,11 @@ class CustomVisionErrorCodes(str, Enum): bad_request_tag_description = "BadRequestTagDescription" bad_request_tag_type = "BadRequestTagType" bad_request_multiple_negative_tag = "BadRequestMultipleNegativeTag" + bad_request_multiple_general_product_tag = "BadRequestMultipleGeneralProductTag" bad_request_image_tags = "BadRequestImageTags" bad_request_image_regions = "BadRequestImageRegions" bad_request_negative_and_regular_tag_on_same_image = "BadRequestNegativeAndRegularTagOnSameImage" + bad_request_unsupported_domain = "BadRequestUnsupportedDomain" bad_request_required_param_is_null = "BadRequestRequiredParamIsNull" bad_request_iteration_is_published = "BadRequestIterationIsPublished" bad_request_invalid_publish_name = "BadRequestInvalidPublishName" @@ -62,6 +64,7 @@ class CustomVisionErrorCodes(str, Enum): bad_request_image_url = "BadRequestImageUrl" bad_request_image_format = "BadRequestImageFormat" bad_request_image_size_bytes = "BadRequestImageSizeBytes" + bad_request_image_dimensions = "BadRequestImageDimensions" bad_request_image_exceeded_count = "BadRequestImageExceededCount" bad_request_training_not_needed = "BadRequestTrainingNotNeeded" bad_request_training_not_needed_but_training_pipeline_updated = "BadRequestTrainingNotNeededButTrainingPipelineUpdated" @@ -86,6 +89,11 @@ class CustomVisionErrorCodes(str, Enum): bad_request_prediction_invalid_query_parameters = "BadRequestPredictionInvalidQueryParameters" bad_request_invalid_import_token = "BadRequestInvalidImportToken" bad_request_export_while_training = "BadRequestExportWhileTraining" + bad_request_image_metadata_key = "BadRequestImageMetadataKey" + bad_request_image_metadata_value = "BadRequestImageMetadataValue" + bad_request_operation_not_supported = "BadRequestOperationNotSupported" + bad_request_invalid_artifact_uri = "BadRequestInvalidArtifactUri" + bad_request_customer_managed_key_revoked = "BadRequestCustomerManagedKeyRevoked" bad_request_invalid = "BadRequestInvalid" unsupported_media_type = "UnsupportedMediaType" forbidden = "Forbidden" @@ -134,6 +142,7 @@ class CustomVisionErrorCodes(str, Enum): error_prediction = "ErrorPrediction" error_prediction_storage = "ErrorPredictionStorage" error_region_proposal = "ErrorRegionProposal" + error_unknown_base_model = "ErrorUnknownBaseModel" error_invalid = "ErrorInvalid" @@ -185,6 +194,21 @@ class ImageCreateStatus(str, Enum): error_negative_and_regular_tag_on_same_image = "ErrorNegativeAndRegularTagOnSameImage" +class ImageMetadataUpdateStatus(str, Enum): + + ok = "OK" + error_image_not_found = "ErrorImageNotFound" + error_limit_exceed = "ErrorLimitExceed" + error_unknown = "ErrorUnknown" + + +class TagType(str, Enum): + + regular = "Regular" + negative = "Negative" + general_product = "GeneralProduct" + + class Classifier(str, Enum): multiclass = "Multiclass" @@ -215,9 +239,3 @@ class SortBy(str, Enum): uncertainty_ascending = "UncertaintyAscending" uncertainty_descending = "UncertaintyDescending" - - -class TagType(str, Enum): - - regular = "Regular" - negative = "Negative" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models.py index 03c972188bfc..5f12784e1207 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models.py @@ -70,19 +70,21 @@ class CustomVisionError(Model): 'BadRequestWorkspaceCannotBeModified', 'BadRequestWorkspaceNotDeletable', 'BadRequestTagName', 'BadRequestTagNameNotUnique', 'BadRequestTagDescription', 'BadRequestTagType', - 'BadRequestMultipleNegativeTag', 'BadRequestImageTags', - 'BadRequestImageRegions', 'BadRequestNegativeAndRegularTagOnSameImage', - 'BadRequestRequiredParamIsNull', 'BadRequestIterationIsPublished', - 'BadRequestInvalidPublishName', 'BadRequestInvalidPublishTarget', - 'BadRequestUnpublishFailed', 'BadRequestIterationNotPublished', - 'BadRequestSubscriptionApi', 'BadRequestExceedProjectLimit', + 'BadRequestMultipleNegativeTag', 'BadRequestMultipleGeneralProductTag', + 'BadRequestImageTags', 'BadRequestImageRegions', + 'BadRequestNegativeAndRegularTagOnSameImage', + 'BadRequestUnsupportedDomain', 'BadRequestRequiredParamIsNull', + 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + 'BadRequestInvalidPublishTarget', 'BadRequestUnpublishFailed', + 'BadRequestIterationNotPublished', 'BadRequestSubscriptionApi', + 'BadRequestExceedProjectLimit', 'BadRequestExceedIterationPerProjectLimit', 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', - 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', - 'BadRequestTrainingNotNeeded', + 'BadRequestImageSizeBytes', 'BadRequestImageDimensions', + 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', 'BadRequestClassificationTrainingValidationFailed', @@ -102,7 +104,10 @@ class CustomVisionError(Model): 'BadRequestPredictionInvalidApplicationName', 'BadRequestPredictionInvalidQueryParameters', 'BadRequestInvalidImportToken', 'BadRequestExportWhileTraining', - 'BadRequestInvalid', 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', + 'BadRequestImageMetadataKey', 'BadRequestImageMetadataValue', + 'BadRequestOperationNotSupported', 'BadRequestInvalidArtifactUri', + 'BadRequestCustomerManagedKeyRevoked', 'BadRequestInvalid', + 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', 'ForbiddenUserResource', 'ForbiddenUserSignupDisabled', 'ForbiddenUserSignupAllowanceExceeded', 'ForbiddenUserDoesNotExist', 'ForbiddenUserDisabled', 'ForbiddenUserInsufficientCapability', @@ -122,7 +127,8 @@ class CustomVisionError(Model): 'ErrorExporterInvalidFeaturizer', 'ErrorExporterInvalidClassifier', 'ErrorPredictionServiceUnavailable', 'ErrorPredictionModelNotFound', 'ErrorPredictionModelNotCached', 'ErrorPrediction', - 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorInvalid' + 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorUnknownBaseModel', + 'ErrorInvalid' :type code: str or ~azure.cognitiveservices.vision.customvision.training.models.CustomVisionErrorCodes :param message: Required. A message explaining the error reported by the @@ -216,7 +222,9 @@ class Export(Model): 'Failed', 'Done' :vartype status: str or ~azure.cognitiveservices.vision.customvision.training.models.ExportStatus - :ivar download_uri: URI used to download the model. + :ivar download_uri: URI used to download the model. If VNET feature is + enabled this will be a relative path to be used with GetArtifact, + otherwise this will be an absolute URI to the resource. :vartype download_uri: str :ivar flavor: Flavor of the export. These are specializations of the export platform. @@ -272,10 +280,16 @@ class Image(Model): :ivar height: Height of the image. :vartype height: int :ivar resized_image_uri: The URI to the (resized) image used for training. + If VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype resized_image_uri: str - :ivar thumbnail_uri: The URI to the thumbnail of the original image. + :ivar thumbnail_uri: The URI to the thumbnail of the original image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str - :ivar original_image_uri: The URI to the original uploaded image. + :ivar original_image_uri: The URI to the original uploaded image. If VNET + feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype original_image_uri: str :ivar tags: Tags associated with this image. :vartype tags: @@ -283,6 +297,8 @@ class Image(Model): :ivar regions: Regions associated with this image. :vartype regions: list[~azure.cognitiveservices.vision.customvision.training.models.ImageRegion] + :ivar metadata: Metadata associated with this image. + :vartype metadata: dict[str, str] """ _validation = { @@ -295,6 +311,7 @@ class Image(Model): 'original_image_uri': {'readonly': True}, 'tags': {'readonly': True}, 'regions': {'readonly': True}, + 'metadata': {'readonly': True}, } _attribute_map = { @@ -307,6 +324,7 @@ class Image(Model): 'original_image_uri': {'key': 'originalImageUri', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '[ImageTag]'}, 'regions': {'key': 'regions', 'type': '[ImageRegion]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__(self, **kwargs): @@ -320,6 +338,7 @@ def __init__(self, **kwargs): self.original_image_uri = None self.tags = None self.regions = None + self.metadata = None class ImageCreateResult(Model): @@ -399,17 +418,23 @@ class ImageFileCreateBatch(Model): list[~azure.cognitiveservices.vision.customvision.training.models.ImageFileCreateEntry] :param tag_ids: :type tag_ids: list[str] + :param metadata: The metadata of image. Limited to 50 key-value pairs per + image. The length of key is limited to 256. The length of value is limited + to 512. + :type metadata: dict[str, str] """ _attribute_map = { 'images': {'key': 'images', 'type': '[ImageFileCreateEntry]'}, 'tag_ids': {'key': 'tagIds', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__(self, **kwargs): super(ImageFileCreateBatch, self).__init__(**kwargs) self.images = kwargs.get('images', None) self.tag_ids = kwargs.get('tag_ids', None) + self.metadata = kwargs.get('metadata', None) class ImageFileCreateEntry(Model): @@ -449,17 +474,23 @@ class ImageIdCreateBatch(Model): list[~azure.cognitiveservices.vision.customvision.training.models.ImageIdCreateEntry] :param tag_ids: :type tag_ids: list[str] + :param metadata: The metadata of image. Limited to 50 key-value pairs per + image. The length of key is limited to 256. The length of value is limited + to 512. + :type metadata: dict[str, str] """ _attribute_map = { 'images': {'key': 'images', 'type': '[ImageIdCreateEntry]'}, 'tag_ids': {'key': 'tagIds', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__(self, **kwargs): super(ImageIdCreateBatch, self).__init__(**kwargs) self.images = kwargs.get('images', None) self.tag_ids = kwargs.get('tag_ids', None) + self.metadata = kwargs.get('metadata', None) class ImageIdCreateEntry(Model): @@ -487,6 +518,61 @@ def __init__(self, **kwargs): self.regions = kwargs.get('regions', None) +class ImageMetadataUpdateEntry(Model): + """Entry associating a metadata to an image. + + :param image_id: Id of the image. + :type image_id: str + :param status: Status of the metadata update. Possible values include: + 'OK', 'ErrorImageNotFound', 'ErrorLimitExceed', 'ErrorUnknown' + :type status: str or + ~azure.cognitiveservices.vision.customvision.training.models.ImageMetadataUpdateStatus + :param metadata: Metadata of the image. + :type metadata: dict[str, str] + """ + + _attribute_map = { + 'image_id': {'key': 'imageId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(ImageMetadataUpdateEntry, self).__init__(**kwargs) + self.image_id = kwargs.get('image_id', None) + self.status = kwargs.get('status', None) + self.metadata = kwargs.get('metadata', None) + + +class ImageMetadataUpdateSummary(Model): + """ImageMetadataUpdateSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar is_batch_successful: + :vartype is_batch_successful: bool + :ivar images: + :vartype images: + list[~azure.cognitiveservices.vision.customvision.training.models.ImageMetadataUpdateEntry] + """ + + _validation = { + 'is_batch_successful': {'readonly': True}, + 'images': {'readonly': True}, + } + + _attribute_map = { + 'is_batch_successful': {'key': 'isBatchSuccessful', 'type': 'bool'}, + 'images': {'key': 'images', 'type': '[ImageMetadataUpdateEntry]'}, + } + + def __init__(self, **kwargs): + super(ImageMetadataUpdateSummary, self).__init__(**kwargs) + self.is_batch_successful = None + self.images = None + + class ImagePerformance(Model): """Image performance model. @@ -994,17 +1080,23 @@ class ImageUrlCreateBatch(Model): list[~azure.cognitiveservices.vision.customvision.training.models.ImageUrlCreateEntry] :param tag_ids: :type tag_ids: list[str] + :param metadata: The metadata of image. Limited to 50 key-value pairs per + image. The length of key is limited to 256. The length of value is limited + to 512. + :type metadata: dict[str, str] """ _attribute_map = { 'images': {'key': 'images', 'type': '[ImageUrlCreateEntry]'}, 'tag_ids': {'key': 'tagIds', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__(self, **kwargs): super(ImageUrlCreateBatch, self).__init__(**kwargs) self.images = kwargs.get('images', None) self.tag_ids = kwargs.get('tag_ids', None) + self.metadata = kwargs.get('metadata', None) class ImageUrlCreateEntry(Model): @@ -1212,6 +1304,10 @@ class Prediction(Model): :ivar bounding_box: Bounding box of the prediction. :vartype bounding_box: ~azure.cognitiveservices.vision.customvision.training.models.BoundingBox + :ivar tag_type: Type of the predicted tag. Possible values include: + 'Regular', 'Negative', 'GeneralProduct' + :vartype tag_type: str or + ~azure.cognitiveservices.vision.customvision.training.models.TagType """ _validation = { @@ -1219,6 +1315,7 @@ class Prediction(Model): 'tag_id': {'readonly': True}, 'tag_name': {'readonly': True}, 'bounding_box': {'readonly': True}, + 'tag_type': {'readonly': True}, } _attribute_map = { @@ -1226,6 +1323,7 @@ class Prediction(Model): 'tag_id': {'key': 'tagId', 'type': 'str'}, 'tag_name': {'key': 'tagName', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, + 'tag_type': {'key': 'tagType', 'type': 'str'}, } def __init__(self, **kwargs): @@ -1234,6 +1332,7 @@ def __init__(self, **kwargs): self.tag_id = None self.tag_name = None self.bounding_box = None + self.tag_type = None class PredictionQueryResult(Model): @@ -1246,7 +1345,7 @@ class PredictionQueryResult(Model): :param token: Prediction Query Token. :type token: ~azure.cognitiveservices.vision.customvision.training.models.PredictionQueryToken - :ivar results: Result of an prediction request. + :ivar results: Result of an image prediction request. :vartype results: list[~azure.cognitiveservices.vision.customvision.training.models.StoredImagePrediction] """ @@ -1361,7 +1460,9 @@ class Project(Model): :vartype created: datetime :ivar last_modified: Gets the date this project was last modified. :vartype last_modified: datetime - :ivar thumbnail_uri: Gets the thumbnail url representing the image. + :ivar thumbnail_uri: Gets the thumbnail url representing the image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str :ivar dr_mode_enabled: Gets if the Disaster Recovery (DR) mode is on, indicating the project is temporarily read-only. @@ -1587,12 +1688,17 @@ class StoredImagePrediction(Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar resized_image_uri: The URI to the (resized) prediction image. + :ivar resized_image_uri: The URI to the (resized) prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype resized_image_uri: str :ivar thumbnail_uri: The URI to the thumbnail of the original prediction - image. + image. If VNET feature is enabled this will be a relative path to be used + with GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str - :ivar original_image_uri: The URI to the original prediction image. + :ivar original_image_uri: The URI to the original prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype original_image_uri: str :ivar domain: Domain used for the prediction. :vartype domain: str @@ -1656,12 +1762,17 @@ class StoredSuggestedTagAndRegion(Model): :vartype width: int :ivar height: Height of the resized image. :vartype height: int - :ivar resized_image_uri: The URI to the (resized) prediction image. + :ivar resized_image_uri: The URI to the (resized) prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype resized_image_uri: str :ivar thumbnail_uri: The URI to the thumbnail of the original prediction - image. + image. If VNET feature is enabled this will be a relative path to be used + with GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str - :ivar original_image_uri: The URI to the original prediction image. + :ivar original_image_uri: The URI to the original prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype original_image_uri: str :ivar domain: Domain used for the prediction. :vartype domain: str @@ -1867,7 +1978,7 @@ class Tag(Model): :param description: Required. Gets or sets the description of the tag. :type description: str :param type: Required. Gets or sets the type of the tag. Possible values - include: 'Regular', 'Negative' + include: 'Regular', 'Negative', 'GeneralProduct' :type type: str or ~azure.cognitiveservices.vision.customvision.training.models.TagType :ivar image_count: Gets the number of images with this tag. diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models_py3.py index 8b0e1f518f20..b41b81244da9 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/models/_models_py3.py @@ -70,19 +70,21 @@ class CustomVisionError(Model): 'BadRequestWorkspaceCannotBeModified', 'BadRequestWorkspaceNotDeletable', 'BadRequestTagName', 'BadRequestTagNameNotUnique', 'BadRequestTagDescription', 'BadRequestTagType', - 'BadRequestMultipleNegativeTag', 'BadRequestImageTags', - 'BadRequestImageRegions', 'BadRequestNegativeAndRegularTagOnSameImage', - 'BadRequestRequiredParamIsNull', 'BadRequestIterationIsPublished', - 'BadRequestInvalidPublishName', 'BadRequestInvalidPublishTarget', - 'BadRequestUnpublishFailed', 'BadRequestIterationNotPublished', - 'BadRequestSubscriptionApi', 'BadRequestExceedProjectLimit', + 'BadRequestMultipleNegativeTag', 'BadRequestMultipleGeneralProductTag', + 'BadRequestImageTags', 'BadRequestImageRegions', + 'BadRequestNegativeAndRegularTagOnSameImage', + 'BadRequestUnsupportedDomain', 'BadRequestRequiredParamIsNull', + 'BadRequestIterationIsPublished', 'BadRequestInvalidPublishName', + 'BadRequestInvalidPublishTarget', 'BadRequestUnpublishFailed', + 'BadRequestIterationNotPublished', 'BadRequestSubscriptionApi', + 'BadRequestExceedProjectLimit', 'BadRequestExceedIterationPerProjectLimit', 'BadRequestExceedTagPerProjectLimit', 'BadRequestExceedTagPerImageLimit', 'BadRequestExceededQuota', 'BadRequestCannotMigrateProjectWithName', 'BadRequestNotLimitedTrial', 'BadRequestImageBatch', 'BadRequestImageStream', 'BadRequestImageUrl', 'BadRequestImageFormat', - 'BadRequestImageSizeBytes', 'BadRequestImageExceededCount', - 'BadRequestTrainingNotNeeded', + 'BadRequestImageSizeBytes', 'BadRequestImageDimensions', + 'BadRequestImageExceededCount', 'BadRequestTrainingNotNeeded', 'BadRequestTrainingNotNeededButTrainingPipelineUpdated', 'BadRequestTrainingValidationFailed', 'BadRequestClassificationTrainingValidationFailed', @@ -102,7 +104,10 @@ class CustomVisionError(Model): 'BadRequestPredictionInvalidApplicationName', 'BadRequestPredictionInvalidQueryParameters', 'BadRequestInvalidImportToken', 'BadRequestExportWhileTraining', - 'BadRequestInvalid', 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', + 'BadRequestImageMetadataKey', 'BadRequestImageMetadataValue', + 'BadRequestOperationNotSupported', 'BadRequestInvalidArtifactUri', + 'BadRequestCustomerManagedKeyRevoked', 'BadRequestInvalid', + 'UnsupportedMediaType', 'Forbidden', 'ForbiddenUser', 'ForbiddenUserResource', 'ForbiddenUserSignupDisabled', 'ForbiddenUserSignupAllowanceExceeded', 'ForbiddenUserDoesNotExist', 'ForbiddenUserDisabled', 'ForbiddenUserInsufficientCapability', @@ -122,7 +127,8 @@ class CustomVisionError(Model): 'ErrorExporterInvalidFeaturizer', 'ErrorExporterInvalidClassifier', 'ErrorPredictionServiceUnavailable', 'ErrorPredictionModelNotFound', 'ErrorPredictionModelNotCached', 'ErrorPrediction', - 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorInvalid' + 'ErrorPredictionStorage', 'ErrorRegionProposal', 'ErrorUnknownBaseModel', + 'ErrorInvalid' :type code: str or ~azure.cognitiveservices.vision.customvision.training.models.CustomVisionErrorCodes :param message: Required. A message explaining the error reported by the @@ -216,7 +222,9 @@ class Export(Model): 'Failed', 'Done' :vartype status: str or ~azure.cognitiveservices.vision.customvision.training.models.ExportStatus - :ivar download_uri: URI used to download the model. + :ivar download_uri: URI used to download the model. If VNET feature is + enabled this will be a relative path to be used with GetArtifact, + otherwise this will be an absolute URI to the resource. :vartype download_uri: str :ivar flavor: Flavor of the export. These are specializations of the export platform. @@ -272,10 +280,16 @@ class Image(Model): :ivar height: Height of the image. :vartype height: int :ivar resized_image_uri: The URI to the (resized) image used for training. + If VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype resized_image_uri: str - :ivar thumbnail_uri: The URI to the thumbnail of the original image. + :ivar thumbnail_uri: The URI to the thumbnail of the original image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str - :ivar original_image_uri: The URI to the original uploaded image. + :ivar original_image_uri: The URI to the original uploaded image. If VNET + feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype original_image_uri: str :ivar tags: Tags associated with this image. :vartype tags: @@ -283,6 +297,8 @@ class Image(Model): :ivar regions: Regions associated with this image. :vartype regions: list[~azure.cognitiveservices.vision.customvision.training.models.ImageRegion] + :ivar metadata: Metadata associated with this image. + :vartype metadata: dict[str, str] """ _validation = { @@ -295,6 +311,7 @@ class Image(Model): 'original_image_uri': {'readonly': True}, 'tags': {'readonly': True}, 'regions': {'readonly': True}, + 'metadata': {'readonly': True}, } _attribute_map = { @@ -307,6 +324,7 @@ class Image(Model): 'original_image_uri': {'key': 'originalImageUri', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '[ImageTag]'}, 'regions': {'key': 'regions', 'type': '[ImageRegion]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } def __init__(self, **kwargs) -> None: @@ -320,6 +338,7 @@ def __init__(self, **kwargs) -> None: self.original_image_uri = None self.tags = None self.regions = None + self.metadata = None class ImageCreateResult(Model): @@ -399,17 +418,23 @@ class ImageFileCreateBatch(Model): list[~azure.cognitiveservices.vision.customvision.training.models.ImageFileCreateEntry] :param tag_ids: :type tag_ids: list[str] + :param metadata: The metadata of image. Limited to 50 key-value pairs per + image. The length of key is limited to 256. The length of value is limited + to 512. + :type metadata: dict[str, str] """ _attribute_map = { 'images': {'key': 'images', 'type': '[ImageFileCreateEntry]'}, 'tag_ids': {'key': 'tagIds', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } - def __init__(self, *, images=None, tag_ids=None, **kwargs) -> None: + def __init__(self, *, images=None, tag_ids=None, metadata=None, **kwargs) -> None: super(ImageFileCreateBatch, self).__init__(**kwargs) self.images = images self.tag_ids = tag_ids + self.metadata = metadata class ImageFileCreateEntry(Model): @@ -449,17 +474,23 @@ class ImageIdCreateBatch(Model): list[~azure.cognitiveservices.vision.customvision.training.models.ImageIdCreateEntry] :param tag_ids: :type tag_ids: list[str] + :param metadata: The metadata of image. Limited to 50 key-value pairs per + image. The length of key is limited to 256. The length of value is limited + to 512. + :type metadata: dict[str, str] """ _attribute_map = { 'images': {'key': 'images', 'type': '[ImageIdCreateEntry]'}, 'tag_ids': {'key': 'tagIds', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } - def __init__(self, *, images=None, tag_ids=None, **kwargs) -> None: + def __init__(self, *, images=None, tag_ids=None, metadata=None, **kwargs) -> None: super(ImageIdCreateBatch, self).__init__(**kwargs) self.images = images self.tag_ids = tag_ids + self.metadata = metadata class ImageIdCreateEntry(Model): @@ -487,6 +518,61 @@ def __init__(self, *, id: str=None, tag_ids=None, regions=None, **kwargs) -> Non self.regions = regions +class ImageMetadataUpdateEntry(Model): + """Entry associating a metadata to an image. + + :param image_id: Id of the image. + :type image_id: str + :param status: Status of the metadata update. Possible values include: + 'OK', 'ErrorImageNotFound', 'ErrorLimitExceed', 'ErrorUnknown' + :type status: str or + ~azure.cognitiveservices.vision.customvision.training.models.ImageMetadataUpdateStatus + :param metadata: Metadata of the image. + :type metadata: dict[str, str] + """ + + _attribute_map = { + 'image_id': {'key': 'imageId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, + } + + def __init__(self, *, image_id: str=None, status=None, metadata=None, **kwargs) -> None: + super(ImageMetadataUpdateEntry, self).__init__(**kwargs) + self.image_id = image_id + self.status = status + self.metadata = metadata + + +class ImageMetadataUpdateSummary(Model): + """ImageMetadataUpdateSummary. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar is_batch_successful: + :vartype is_batch_successful: bool + :ivar images: + :vartype images: + list[~azure.cognitiveservices.vision.customvision.training.models.ImageMetadataUpdateEntry] + """ + + _validation = { + 'is_batch_successful': {'readonly': True}, + 'images': {'readonly': True}, + } + + _attribute_map = { + 'is_batch_successful': {'key': 'isBatchSuccessful', 'type': 'bool'}, + 'images': {'key': 'images', 'type': '[ImageMetadataUpdateEntry]'}, + } + + def __init__(self, **kwargs) -> None: + super(ImageMetadataUpdateSummary, self).__init__(**kwargs) + self.is_batch_successful = None + self.images = None + + class ImagePerformance(Model): """Image performance model. @@ -994,17 +1080,23 @@ class ImageUrlCreateBatch(Model): list[~azure.cognitiveservices.vision.customvision.training.models.ImageUrlCreateEntry] :param tag_ids: :type tag_ids: list[str] + :param metadata: The metadata of image. Limited to 50 key-value pairs per + image. The length of key is limited to 256. The length of value is limited + to 512. + :type metadata: dict[str, str] """ _attribute_map = { 'images': {'key': 'images', 'type': '[ImageUrlCreateEntry]'}, 'tag_ids': {'key': 'tagIds', 'type': '[str]'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, } - def __init__(self, *, images=None, tag_ids=None, **kwargs) -> None: + def __init__(self, *, images=None, tag_ids=None, metadata=None, **kwargs) -> None: super(ImageUrlCreateBatch, self).__init__(**kwargs) self.images = images self.tag_ids = tag_ids + self.metadata = metadata class ImageUrlCreateEntry(Model): @@ -1212,6 +1304,10 @@ class Prediction(Model): :ivar bounding_box: Bounding box of the prediction. :vartype bounding_box: ~azure.cognitiveservices.vision.customvision.training.models.BoundingBox + :ivar tag_type: Type of the predicted tag. Possible values include: + 'Regular', 'Negative', 'GeneralProduct' + :vartype tag_type: str or + ~azure.cognitiveservices.vision.customvision.training.models.TagType """ _validation = { @@ -1219,6 +1315,7 @@ class Prediction(Model): 'tag_id': {'readonly': True}, 'tag_name': {'readonly': True}, 'bounding_box': {'readonly': True}, + 'tag_type': {'readonly': True}, } _attribute_map = { @@ -1226,6 +1323,7 @@ class Prediction(Model): 'tag_id': {'key': 'tagId', 'type': 'str'}, 'tag_name': {'key': 'tagName', 'type': 'str'}, 'bounding_box': {'key': 'boundingBox', 'type': 'BoundingBox'}, + 'tag_type': {'key': 'tagType', 'type': 'str'}, } def __init__(self, **kwargs) -> None: @@ -1234,6 +1332,7 @@ def __init__(self, **kwargs) -> None: self.tag_id = None self.tag_name = None self.bounding_box = None + self.tag_type = None class PredictionQueryResult(Model): @@ -1246,7 +1345,7 @@ class PredictionQueryResult(Model): :param token: Prediction Query Token. :type token: ~azure.cognitiveservices.vision.customvision.training.models.PredictionQueryToken - :ivar results: Result of an prediction request. + :ivar results: Result of an image prediction request. :vartype results: list[~azure.cognitiveservices.vision.customvision.training.models.StoredImagePrediction] """ @@ -1361,7 +1460,9 @@ class Project(Model): :vartype created: datetime :ivar last_modified: Gets the date this project was last modified. :vartype last_modified: datetime - :ivar thumbnail_uri: Gets the thumbnail url representing the image. + :ivar thumbnail_uri: Gets the thumbnail url representing the image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str :ivar dr_mode_enabled: Gets if the Disaster Recovery (DR) mode is on, indicating the project is temporarily read-only. @@ -1587,12 +1688,17 @@ class StoredImagePrediction(Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar resized_image_uri: The URI to the (resized) prediction image. + :ivar resized_image_uri: The URI to the (resized) prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype resized_image_uri: str :ivar thumbnail_uri: The URI to the thumbnail of the original prediction - image. + image. If VNET feature is enabled this will be a relative path to be used + with GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str - :ivar original_image_uri: The URI to the original prediction image. + :ivar original_image_uri: The URI to the original prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype original_image_uri: str :ivar domain: Domain used for the prediction. :vartype domain: str @@ -1656,12 +1762,17 @@ class StoredSuggestedTagAndRegion(Model): :vartype width: int :ivar height: Height of the resized image. :vartype height: int - :ivar resized_image_uri: The URI to the (resized) prediction image. + :ivar resized_image_uri: The URI to the (resized) prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype resized_image_uri: str :ivar thumbnail_uri: The URI to the thumbnail of the original prediction - image. + image. If VNET feature is enabled this will be a relative path to be used + with GetArtifact, otherwise this will be an absolute URI to the resource. :vartype thumbnail_uri: str - :ivar original_image_uri: The URI to the original prediction image. + :ivar original_image_uri: The URI to the original prediction image. If + VNET feature is enabled this will be a relative path to be used with + GetArtifact, otherwise this will be an absolute URI to the resource. :vartype original_image_uri: str :ivar domain: Domain used for the prediction. :vartype domain: str @@ -1867,7 +1978,7 @@ class Tag(Model): :param description: Required. Gets or sets the description of the tag. :type description: str :param type: Required. Gets or sets the type of the tag. Possible values - include: 'Regular', 'Negative' + include: 'Regular', 'Negative', 'GeneralProduct' :type type: str or ~azure.cognitiveservices.vision.customvision.training.models.TagType :ivar image_count: Gets the number of images with this tag. diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/operations/_custom_vision_training_client_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/operations/_custom_vision_training_client_operations.py index b9c93e6cd9d8..a8780ab7a40d 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/operations/_custom_vision_training_client_operations.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/training/operations/_custom_vision_training_client_operations.py @@ -10,6 +10,7 @@ # -------------------------------------------------------------------------- from msrest.pipeline import ClientRawResponse +from msrest.exceptions import HttpOperationError from .. import models @@ -397,6 +398,64 @@ def update_project( return deserialized update_project.metadata = {'url': '/projects/{projectId}'} + def get_artifact( + self, project_id, path, custom_headers=None, raw=False, callback=None, **operation_config): + """Get artifact content from blob storage, based on artifact relative path + in the blob. + + :param project_id: The project id. + :type project_id: str + :param path: The relative path for artifact. + :type path: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param callback: When specified, will be called with each chunk of + data that is streamed. The callback should take two arguments, the + bytes of the current chunk of data and the response object. If the + data is uploading, response will be None. + :type callback: Callable[Bytes, response=None] + :param operation_config: :ref:`Operation configuration + overrides`. + :return: object or ClientRawResponse if raw=true + :rtype: Generator or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`HttpOperationError` + """ + # Construct URL + url = self.get_artifact.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'projectId': self._serialize.url("project_id", project_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['path'] = self._serialize.query("path", path, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/octet-stream' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=True, **operation_config) + + if response.status_code not in [200]: + raise HttpOperationError(self._deserialize, response) + + deserialized = self._client.stream_download(response, callback) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_artifact.metadata = {'url': '/projects/{projectId}/artifacts'} + def export_project( self, project_id, custom_headers=None, raw=False, **operation_config): """Exports a project. @@ -450,6 +509,107 @@ def export_project( return deserialized export_project.metadata = {'url': '/projects/{projectId}/export'} + def get_images( + self, project_id, iteration_id=None, tag_ids=None, tagging_status=None, filter=None, order_by=None, take=50, skip=0, custom_headers=None, raw=False, **operation_config): + """Get images for a given project iteration or workspace. + + This API supports batching and range selection. By default it will only + return first 50 images matching images. + Use the {take} and {skip} parameters to control how many images to + return in a given batch. + The filtering is on an and/or relationship. For example, if the + provided tag ids are for the "Dog" and + "Cat" tags, then only images tagged with Dog and/or Cat will be + returned. + + :param project_id: The project id. + :type project_id: str + :param iteration_id: The iteration id. Defaults to workspace. + :type iteration_id: str + :param tag_ids: A list of tags ids to filter the images. Defaults to + all tagged images when null. Limited to 20. + :type tag_ids: list[str] + :param tagging_status: The tagging status filter. It can be 'All', + 'Tagged', or 'Untagged'. Defaults to 'All'. Possible values include: + 'All', 'Tagged', 'Untagged' + :type tagging_status: str + :param filter: An expression to filter the images against image + metadata. Only images where the expression evaluates to true are + included in the response. + The expression supports eq (Equal), ne (Not equal), and (Logical and), + or (Logical or) operators. + Here is an example, metadata=key1 eq 'value1' and key2 ne 'value2'. + :type filter: str + :param order_by: The ordering. Defaults to newest. Possible values + include: 'Newest', 'Oldest' + :type order_by: str + :param take: Maximum number of images to return. Defaults to 50, + limited to 256. + :type take: int + :param skip: Number of images to skip before beginning the image + batch. Defaults to 0. + :type skip: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: list or ClientRawResponse if raw=true + :rtype: + list[~azure.cognitiveservices.vision.customvision.training.models.Image] + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`CustomVisionErrorException` + """ + # Construct URL + url = self.get_images.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'projectId': self._serialize.url("project_id", project_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if iteration_id is not None: + query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str') + if tag_ids is not None: + query_parameters['tagIds'] = self._serialize.query("tag_ids", tag_ids, '[str]', div=',', max_items=20, min_items=0) + if tagging_status is not None: + query_parameters['taggingStatus'] = self._serialize.query("tagging_status", tagging_status, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if order_by is not None: + query_parameters['orderBy'] = self._serialize.query("order_by", order_by, 'str') + if take is not None: + query_parameters['take'] = self._serialize.query("take", take, 'int', maximum=256, minimum=0) + if skip is not None: + query_parameters['skip'] = self._serialize.query("skip", skip, 'int') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.CustomVisionErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('[Image]', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_images.metadata = {'url': '/projects/{projectId}/images'} + def create_images_from_data( self, project_id, image_data, tag_ids=None, custom_headers=None, raw=False, **operation_config): """Add the provided images to the set of training images. @@ -457,6 +617,10 @@ def create_images_from_data( This API accepts body content as multipart/form-data and application/octet-stream. When using multipart multiple image files can be sent at once, with a maximum of 64 files. + If all images are successful created, 200(OK) status code will be + returned. + Otherwise, 207 (Multi-Status) status code will be returned and detail + status for each image will be listed in the response payload. :param project_id: The project id. :type project_id: str @@ -507,12 +671,14 @@ def create_images_from_data( request = self._client.post(url, query_parameters, header_parameters, form_content=form_data_content) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 207]: raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageCreateSummary', response) + if response.status_code == 207: + deserialized = self._deserialize('ImageCreateSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -642,20 +808,103 @@ def get_image_region_proposals( return deserialized get_image_region_proposals.metadata = {'url': '/projects/{projectId}/images/{imageId}/regionproposals'} + def get_image_count( + self, project_id, iteration_id=None, tagging_status=None, filter=None, tag_ids=None, custom_headers=None, raw=False, **operation_config): + """Get the number of images. + + The filtering is on an and/or relationship. For example, if the + provided tag ids are for the "Dog" and + "Cat" tags, then only images tagged with Dog and/or Cat will be + returned. + + :param project_id: The project id. + :type project_id: str + :param iteration_id: The iteration id. Defaults to workspace. + :type iteration_id: str + :param tagging_status: The tagging status filter. It can be 'All', + 'Tagged', or 'Untagged'. Defaults to 'All'. Possible values include: + 'All', 'Tagged', 'Untagged' + :type tagging_status: str + :param filter: An expression to filter the images against image + metadata. Only images where the expression evaluates to true are + included in the response. + The expression supports eq (Equal), ne (Not equal), and (Logical and), + or (Logical or) operators. + Here is an example, metadata=key1 eq 'value1' and key2 ne 'value2'. + :type filter: str + :param tag_ids: A list of tags ids to filter the images to count. + Defaults to all tags when null. + :type tag_ids: list[str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: int or ClientRawResponse if raw=true + :rtype: int or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`CustomVisionErrorException` + """ + # Construct URL + url = self.get_image_count.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'projectId': self._serialize.url("project_id", project_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if iteration_id is not None: + query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str') + if tagging_status is not None: + query_parameters['taggingStatus'] = self._serialize.query("tagging_status", tagging_status, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if tag_ids is not None: + query_parameters['tagIds'] = self._serialize.query("tag_ids", tag_ids, '[str]', div=',') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.CustomVisionErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('int', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_image_count.metadata = {'url': '/projects/{projectId}/images/count'} + def create_images_from_files( - self, project_id, images=None, tag_ids=None, custom_headers=None, raw=False, **operation_config): + self, project_id, batch, custom_headers=None, raw=False, **operation_config): """Add the provided batch of images to the set of training images. This API accepts a batch of files, and optionally tags, to create images. There is a limit of 64 images and 20 tags. + If all images are successful created, 200(OK) status code will be + returned. + Otherwise, 207 (Multi-Status) status code will be returned and detail + status for each image will be listed in the response payload. :param project_id: The project id. :type project_id: str - :param images: - :type images: - list[~azure.cognitiveservices.vision.customvision.training.models.ImageFileCreateEntry] - :param tag_ids: - :type tag_ids: list[str] + :param batch: The batch of image files to add. Limited to 64 images + and 20 tags per batch. + :type batch: + ~azure.cognitiveservices.vision.customvision.training.models.ImageFileCreateBatch :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -668,8 +917,6 @@ def create_images_from_files( :raises: :class:`CustomVisionErrorException` """ - batch = models.ImageFileCreateBatch(images=images, tag_ids=tag_ids) - # Construct URL url = self.create_images_from_files.metadata['url'] path_format_arguments = { @@ -695,12 +942,14 @@ def create_images_from_files( request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 207]: raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageCreateSummary', response) + if response.status_code == 207: + deserialized = self._deserialize('ImageCreateSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -774,20 +1023,92 @@ def get_images_by_ids( return deserialized get_images_by_ids.metadata = {'url': '/projects/{projectId}/images/id'} + def update_image_metadata( + self, project_id, image_ids, metadata, custom_headers=None, raw=False, **operation_config): + """Update metadata of images. + + This API accepts a batch of image Ids, and metadata, to update images. + There is a limit of 64 images. + + :param project_id: The project id. + :type project_id: str + :param image_ids: The list of image ids to update. Limited to 64. + :type image_ids: list[str] + :param metadata: The metadata to be updated to the specified images. + Limited to 50 key-value pairs per image. The length of key is limited + to 256. The length of value is limited to 512. + :type metadata: dict[str, str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ImageMetadataUpdateSummary or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.vision.customvision.training.models.ImageMetadataUpdateSummary + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`CustomVisionErrorException` + """ + # Construct URL + url = self.update_image_metadata.metadata['url'] + path_format_arguments = { + 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), + 'projectId': self._serialize.url("project_id", project_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['imageIds'] = self._serialize.query("image_ids", image_ids, '[str]', div=',', max_items=256, min_items=0) + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(metadata, '{str}') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 207]: + raise models.CustomVisionErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ImageMetadataUpdateSummary', response) + if response.status_code == 207: + deserialized = self._deserialize('ImageMetadataUpdateSummary', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update_image_metadata.metadata = {'url': '/projects/{projectId}/images/metadata'} + def create_images_from_predictions( - self, project_id, images=None, tag_ids=None, custom_headers=None, raw=False, **operation_config): + self, project_id, batch, custom_headers=None, raw=False, **operation_config): """Add the specified predicted images to the set of training images. This API creates a batch of images from predicted images specified. There is a limit of 64 images and 20 tags. + If all images are successful created, 200(OK) status code will be + returned. + Otherwise, 207 (Multi-Status) status code will be returned and detail + status for each image will be listed in the response payload. :param project_id: The project id. :type project_id: str - :param images: - :type images: - list[~azure.cognitiveservices.vision.customvision.training.models.ImageIdCreateEntry] - :param tag_ids: - :type tag_ids: list[str] + :param batch: Image, tag ids, and metadata. Limited to 64 images and + 20 tags per batch. + :type batch: + ~azure.cognitiveservices.vision.customvision.training.models.ImageIdCreateBatch :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -800,8 +1121,6 @@ def create_images_from_predictions( :raises: :class:`CustomVisionErrorException` """ - batch = models.ImageIdCreateBatch(images=images, tag_ids=tag_ids) - # Construct URL url = self.create_images_from_predictions.metadata['url'] path_format_arguments = { @@ -827,12 +1146,14 @@ def create_images_from_predictions( request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 207]: raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageCreateSummary', response) + if response.status_code == 207: + deserialized = self._deserialize('ImageCreateSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -848,6 +1169,10 @@ def create_image_regions( This API accepts a batch of image regions, and optionally tags, to update existing images with region information. There is a limit of 64 entries in the batch. + If all regions are successful created, 200(OK) status code will be + returned. + Otherwise, 207 (Multi-Status) status code will be returned and detail + status for each region will be listed in the response payload. :param project_id: The project id. :type project_id: str @@ -893,12 +1218,14 @@ def create_image_regions( request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 207]: raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageRegionCreateSummary', response) + if response.status_code == 207: + deserialized = self._deserialize('ImageRegionCreateSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -1494,19 +1821,22 @@ def get_untagged_image_count( get_untagged_image_count.metadata = {'url': '/projects/{projectId}/images/untagged/count'} def create_images_from_urls( - self, project_id, images=None, tag_ids=None, custom_headers=None, raw=False, **operation_config): + self, project_id, batch, custom_headers=None, raw=False, **operation_config): """Add the provided images urls to the set of training images. This API accepts a batch of urls, and optionally tags, to create images. There is a limit of 64 images and 20 tags. + If all images are successful created, 200(OK) status code will be + returned. + Otherwise, 207 (Multi-Status) status code will be returned and detail + status for each image will be listed in the response payload. :param project_id: The project id. :type project_id: str - :param images: - :type images: - list[~azure.cognitiveservices.vision.customvision.training.models.ImageUrlCreateEntry] - :param tag_ids: - :type tag_ids: list[str] + :param batch: Image urls, tag ids, and metadata. Limited to 64 images + and 20 tags per batch. + :type batch: + ~azure.cognitiveservices.vision.customvision.training.models.ImageUrlCreateBatch :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -1519,8 +1849,6 @@ def create_images_from_urls( :raises: :class:`CustomVisionErrorException` """ - batch = models.ImageUrlCreateBatch(images=images, tag_ids=tag_ids) - # Construct URL url = self.create_images_from_urls.metadata['url'] path_format_arguments = { @@ -1546,12 +1874,14 @@ def create_images_from_urls( request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 207]: raise models.CustomVisionErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ImageCreateSummary', response) + if response.status_code == 207: + deserialized = self._deserialize('ImageCreateSummary', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -2119,7 +2449,7 @@ def get_image_performance_count( get_image_performance_count.metadata = {'url': '/projects/{projectId}/iterations/{iterationId}/performance/images/count'} def publish_iteration( - self, project_id, iteration_id, publish_name, prediction_id, custom_headers=None, raw=False, **operation_config): + self, project_id, iteration_id, publish_name, prediction_id, overwrite=None, custom_headers=None, raw=False, **operation_config): """Publish a specific iteration. :param project_id: The project id. @@ -2130,6 +2460,9 @@ def publish_iteration( :type publish_name: str :param prediction_id: The id of the prediction resource to publish to. :type prediction_id: str + :param overwrite: Whether to overwrite the published model with the + given name (default: false). + :type overwrite: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -2153,6 +2486,8 @@ def publish_iteration( query_parameters = {} query_parameters['publishName'] = self._serialize.query("publish_name", publish_name, 'str') query_parameters['predictionId'] = self._serialize.query("prediction_id", prediction_id, 'str') + if overwrite is not None: + query_parameters['overwrite'] = self._serialize.query("overwrite", overwrite, 'bool') # Construct headers header_parameters = {} @@ -2547,7 +2882,7 @@ def create_tag( :param description: Optional description for the tag. :type description: str :param type: Optional type for the tag. Possible values include: - 'Regular', 'Negative' + 'Regular', 'Negative', 'GeneralProduct' :type type: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the @@ -2926,11 +3261,14 @@ def train_project( train_project.metadata = {'url': '/projects/{projectId}/train'} def import_project( - self, token, custom_headers=None, raw=False, **operation_config): + self, token, name=None, custom_headers=None, raw=False, **operation_config): """Imports a project. :param token: Token generated from the export project call. :type token: str + :param name: Optional, name of the project to use instead of + auto-generated name. + :type name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -2953,6 +3291,8 @@ def import_project( # Construct parameters query_parameters = {} query_parameters['token'] = self._serialize.query("token", token, 'str') + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') # Construct headers header_parameters = {} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/version.py b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/version.py index a89ae9805392..69dfaa9ef877 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/version.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-vision-customvision/azure/cognitiveservices/vision/customvision/version.py @@ -9,4 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md b/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md index cfcc7560a734..b283fa6eae23 100644 --- a/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md @@ -1,6 +1,8 @@ # Release History ## 4.2.0b2 (Unreleased) +- Values of `x-ms-keyvault-region` and `x-ms-keyvault-service-version` headers + are no longer redacted in logging output. - Updated minimum `azure-core` version to 1.4.0 ## 4.2.0b1 (2020-03-10) diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py index 75c3196d8a5f..45475cbc5723 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_shared/client_base.py @@ -26,6 +26,12 @@ class ApiVersion(str, Enum): V7_0 = "7.0" V2016_10_01 = "2016-10-01" +def _get_policies(config, **kwargs): + logging_policy = HttpLoggingPolicy(**kwargs) + logging_policy.allowed_header_names.update( + {"x-ms-keyvault-network-info", "x-ms-keyvault-region", "x-ms-keyvault-service-version"} + ) + DEFAULT_VERSION = ApiVersion.V7_1_preview diff --git a/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md b/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md index 09e6365abe27..03d3eae08261 100644 --- a/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md @@ -1,6 +1,8 @@ # Release History ## 4.2.0b2 (Unreleased) +- Values of `x-ms-keyvault-region` and `x-ms-keyvault-service-version` headers + are no longer redacted in logging output. - Updated minimum `azure-core` version to 1.4.0 - `CryptographyClient` will no longer perform encrypt or wrap operations when its key has expired or is not yet valid. diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py index b1e1a2e997d2..6fccbaf5780e 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/client_base.py @@ -27,7 +27,9 @@ def _get_policies(config, **kwargs): logging_policy = HttpLoggingPolicy(**kwargs) - logging_policy.allowed_header_names.add("x-ms-keyvault-network-info") + logging_policy.allowed_header_names.update( + {"x-ms-keyvault-network-info", "x-ms-keyvault-region", "x-ms-keyvault-service-version"} + ) return [ config.headers_policy, diff --git a/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md b/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md index 206b9feea689..f13360a8f8b6 100644 --- a/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md @@ -1,6 +1,8 @@ # Release History ## 4.2.0b2 (Unreleased) +- Values of `x-ms-keyvault-region` and `x-ms-keyvault-service-version` headers + are no longer redacted in logging output. - Updated minimum `azure-core` version to 1.4.0 ## 4.2.0b1 (2020-03-10) diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py index b1e1a2e997d2..6fccbaf5780e 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/client_base.py @@ -27,7 +27,9 @@ def _get_policies(config, **kwargs): logging_policy = HttpLoggingPolicy(**kwargs) - logging_policy.allowed_header_names.add("x-ms-keyvault-network-info") + logging_policy.allowed_header_names.update( + {"x-ms-keyvault-network-info", "x-ms-keyvault-region", "x-ms-keyvault-service-version"} + ) return [ config.headers_policy, diff --git a/sdk/servicebus/azure-servicebus/swagger/servicebus-swagger.json b/sdk/servicebus/azure-servicebus/swagger/servicebus-swagger.json deleted file mode 100644 index 981615cac716..000000000000 --- a/sdk/servicebus/azure-servicebus/swagger/servicebus-swagger.json +++ /dev/null @@ -1,960 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "2017_04", - "title": "ServiceBusManagementClient", - "description": "Azure Service Bus client for managing Queues, Topics, and Subscriptions.", - "x-ms-code-generation-settings": { - "internalConstructors": true, - "name": "ServiceBusManagementClient" - } - }, - "x-ms-parameterized-host": { - "hostTemplate": "{endpoint}", - "parameters": [ - { - "$ref": "#/parameters/Endpoint" - } - ] - }, - "schemes": [ - "https" - ], - "produces": [ - "application/xml" - ], - "consumes": [ - "application/xml" - ], - "tags": [ - { - "name": "Queue Operations" - }, - { - "name": "Topic Operations" - }, - { - "name": "Subscription Operations" - } - ], - "parameters": { - "ApiVersion": { - "name": "api-version", - "in": "query", - "type": "string", - "default": "2017-04", - "description": "Specifies the version of the REST protocol used for processing the request. This is required when using shared key authorization.", - "minLength": 1, - "x-ms-parameter-location": "client" - }, - "Endpoint": { - "in": "path", - "name": "endpoint", - "description": "The Service Bus fully qualified domain name.", - "required": true, - "type": "string", - "x-ms-skip-url-encoding": true, - "x-ms-parameter-location": "client" - }, - "Enrich": { - "name": "enrich", - "in": "query", - "description": "A query parameter that sets enrich to true or false.", - "type": "boolean", - "default": false, - "x-ms-parameter-location": "method" - } - }, - "definitions": { - "AccessRights": { - "description": "Access rights of the entity", - "type": "string", - "xml": { - "name": "AccessRights", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "enum": [ - "Manage", - "Send", - "Listen" - ] - }, - "AuthorizationRule": { - "description": "Authorization rule of an entity", - "type": "object", - "xml": { - "name": "AuthorizationRule", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "properties": { - "type": { - "type": "string", - "xml": { - "attribute": true, - "prefix": "i", - "namespace": "http://www.w3.org/2001/XMLSchema-instance" - } - }, - "ClaimType": { - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "ClaimValue": { - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "Rights": { - "description": "Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'", - "type": "array", - "xml": { - "wrapped": true, - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "items": { - "type": "string", - "xml": { - "name": "AccessRights", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - } - }, - "CreatedTime": { - "description": "The date and time when the authorization rule was created.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "ModifiedTime": { - "description": "The date and time when the authorization rule was modified.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "KeyName": { - "description": "The authorization rule key name", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "PrimaryKey": { - "description": "The primary key of the authorization rule", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "SecondaryKey": { - "description": "The primary key of the authorization rule", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - } - } - }, - "CreateQueueBody": { - "description": "The request body for creating a queue.", - "type": "object", - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "content": { - "description": "QueueDescription for the new queue.", - "type": "object", - "xml": { - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "type": { - "description": "MIME type of content.", - "type": "string", - "default": "application/xml", - "xml": { - "attribute": true - } - }, - "QueueDescription": { - "description": "Properties of the new queue.", - "$ref": "#/definitions/QueueDescription" - } - } - } - } - }, - "CreateTopicBody": { - "description": "The request body for creating a topic.", - "type": "object", - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "content": { - "description": "TopicDescription for the new topic.", - "type": "object", - "xml": { - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "type": { - "description": "MIME type of content.", - "type": "string", - "default": "application/xml", - "xml": { - "attribute": true - } - }, - "TopicDescription": { - "description": "Topic information to create.", - "$ref": "#/definitions/TopicDescription" - } - } - } - } - }, - "EntityAvailabilityStatus": { - "description": "Availibility status of the entity", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "enum": [ - "Available", - "Limited", - "Renaming", - "Restoring", - "Unknown" - ] - }, - "EntityStatus": { - "description": "Status of a Service Bus resource", - "type": "string", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "enum": [ - "Active", - "Creating", - "Deleting", - "Disabled", - "ReceiveDisabled", - "Renaming", - "Restoring", - "SendDisabled", - "Unknown" - ] - }, - "MessageCountDetails": { - "description": "Details about the message counts in queue.", - "type": "object", - "properties": { - "ActiveMessageCount": { - "description": "Number of active messages in the queue, topic, or subscription.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "DeadLetterMessageCount": { - "description": "Number of messages that are dead lettered.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "ScheduledMessageCount": { - "description": "Number of scheduled messages.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "TransferDeadLetterMessageCount": { - "description": "Number of messages transferred into dead letters.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - }, - "TransferMessageCount": { - "description": "Number of messages transferred to another queue, topic, or subscription.", - "type": "integer", - "xml": { - "prefix": "d2p1", - "namespace": "http://schemas.microsoft.com/netservices/2011/06/servicebus" - } - } - }, - "xml": { - "name": "CountDetails", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "QueueDescription": { - "description": "Description of a Service Bus queue resource.", - "type": "object", - "xml": { - "name": "QueueDescription", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "properties": { - "AuthorizationRules": { - "description": "Authorization rules for resource.", - "type": "array", - "xml": { - "name": "AuthorizationRules", - "wrapped": true, - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "items": { - "$ref": "#/definitions/AuthorizationRule" - } - }, - "AutoDeleteOnIdle": { - "description": "ISO 8601 timeSpan idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "CreatedAt": { - "description": "The exact time the queue was created.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DeadLetteringOnMessageExpiration": { - "description": "A value that indicates whether this queue has dead letter support when a message expires.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DefaultMessageTimeToLive": { - "description": "ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DuplicateDetectionHistoryTimeWindow": { - "description": "ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EntityAvailabilityStatus": { - "$ref": "#/definitions/EntityAvailabilityStatus" - }, - "EnableBatchedOperations": { - "description": "Value that indicates whether server-side batched operations are enabled.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnableExpress": { - "description": "A value that indicates whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing it to persistent storage.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnablePartitioning": { - "description": "A value that indicates whether the queue is to be partitioned across multiple message brokers.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "IsAnonymousAccessible": { - "description": "A value indicating if the resource can be accessed without authorization.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "LockDuration": { - "description": "ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MaxDeliveryCount": { - "description": "The maximum delivery count. A message is automatically deadlettered after this number of deliveries. Default value is 10.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MaxSizeInMegabytes": { - "description": "The maximum size of the queue in megabytes, which is the size of memory allocated for the queue.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "RequiresDuplicateDetection": { - "description": "A value indicating if this queue requires duplicate detection.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "RequiresSession": { - "description": "A value that indicates whether the queue supports the concept of sessions.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "Status": { - "$ref": "#/definitions/EntityStatus" - }, - "SupportOrdering": { - "description": "A value that indicates whether the queue supports ordering.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "AccessedAt": { - "description": "Last time a message was sent, or the last time there was a receive request to this queue.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "UpdatedAt": { - "description": "The exact time a message was updated in the queue.", - "type": "string", - "format": "date-time", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "SizeInBytes": { - "description": "The size of the queue, in bytes.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MessageCount": { - "description": "The number of messages in the queue.", - "type": "integer", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MessageCountDetails": { - "$ref": "#/definitions/MessageCountDetails" - } - } - }, - "QueueDescriptionEntry": { - "description": "Represents an entry in the feed when querying queues", - "type": "object", - "properties": { - "base": { - "description": "Base URL for the query.", - "type": "string", - "xml": { - "name": "base", - "attribute": true, - "prefix": "xml" - } - }, - "id": { - "description": "The URL of the GET request", - "type": "string" - }, - "title": { - "description": "The name of the queue", - "$ref": "#/definitions/ResponseTitle" - }, - "published": { - "description": "The timestamp for when this queue was published", - "type": "string", - "format": "date-time" - }, - "updated": { - "description": "The timestamp for when this queue was last updated", - "type": "string", - "format": "date-time" - }, - "author": { - "$ref": "#/definitions/ResponseAuthor" - }, - "link": { - "$ref": "#/definitions/ResponseLink" - }, - "content": { - "description": "The QueueDescription", - "type": "object", - "properties": { - "type": { - "description": "Type of content in queue response", - "type": "string", - "xml": { - "attribute": true - } - }, - "QueueDescription": { - "$ref": "#/definitions/QueueDescription" - } - } - } - }, - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - } - }, - "QueueDescriptionFeed": { - "description": "Response from listing Service Bus queues.", - "type": "object", - "xml": { - "name": "feed", - "namespace": "http://www.w3.org/2005/Atom" - }, - "properties": { - "id": { - "description": "URL of the list queues query.", - "type": "string" - }, - "title": { - "description": "The entity type for the feed.", - "type": "string" - }, - "updated": { - "description": "Datetime of the query.", - "type": "string", - "format": "date-time" - }, - "link": { - "description": "Links to paginated response.", - "type":"array", - "items": { - "$ref": "#/definitions/ResponseLink" - } - }, - "entry": { - "description": "Queue entries.", - "type": "array", - "items": { - "$ref": "#/definitions/QueueDescriptionEntry" - } - } - } - }, - "QueueDescriptionResponse": { - "description": "The response from a Queue_Get operation", - "type": "object", - "properties": { - "id": { - "description": "The URL of the GET request", - "type": "string" - }, - "title": { - "description": "The name of the queue", - "type": "string" - }, - "published": { - "description": "The timestamp for when this queue was published", - "type": "string" - }, - "updated": { - "description": "The timestamp for when this queue was last updated", - "type": "string" - }, - "author": { - "$ref": "#/definitions/ResponseAuthor" - }, - "link": { - "$ref": "#/definitions/ResponseLink" - }, - "content": { - "description": "Contents of a Queue_Get response", - "type": "object", - "properties": { - "type": { - "description": "Type of content in queue response", - "type": "string", - "xml": { - "attribute": true - } - }, - "QueueDescription": { - "$ref": "#/definitions/QueueDescription" - } - } - } - }, - "xml": { - "name": "entry", - "namespace": "http://www.w3.org/2005/Atom" - } - }, - "ResponseAuthor": { - "description": "The author that created this resource", - "type": "object", - "properties": { - "name": { - "description": "The Service Bus namespace", - "type": "string" - } - } - }, - "ResponseLink": { - "description": "The URL for the HTTP request", - "type": "object", - "properties": { - "href": { - "description": "The URL of the GET request", - "type": "string", - "xml": { - "attribute": true - } - }, - "rel": { - "description": "What the link href is relative to", - "type": "string", - "xml": { - "attribute": true - } - } - }, - "xml": { - "name": "link", - "namespace": "http://www.w3.org/2005/Atom" - } - }, - "ResponseTitle": { - "description": "The title of the response", - "type": "object", - "properties": { - "type": { - "description": "Type of value", - "type": "string", - "xml": { - "attribute": true - } - }, - "title": { - "description": "Contents of the title.", - "type": "string" - } - } - }, - "ServiceBusManagementError": { - "description": "The error response from Service Bus.", - "type": "object", - "properties": { - "Code": { - "description": "The service error code.", - "type": "integer" - }, - "Detail": { - "description": "The service error message.", - "type": "string" - } - } - }, - "TopicDescription": { - "description": "Description of a Service Bus topic resource.", - "type": "object", - "xml": { - "name": "TopicDescription", - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "properties": { - "TopicName": { - "description": "Name of the topic", - "type": "string" - }, - "AuthorizationRules": { - "description": "Authorization rules for resource.", - "type": "array", - "xml": { - "wrapped": true, - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - }, - "items": { - "$ref": "#/definitions/AuthorizationRule" - } - }, - "AutoDeleteOnIdle": { - "description": "ISO 8601 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DefaultMessageTimeToLive": { - "description": "ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "DuplicateDetectionHistoryTimeWindow": { - "description": "ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes.", - "type": "string", - "format": "duration", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnableBatchedOperations": { - "description": "Value that indicates whether server-side batched operations are enabled.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "EnablePartitioning": { - "description": "A value that indicates whether the topic is to be partitioned across multiple message brokers.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "MaxSizeInMegabytes": { - "description": "The maximum size of the topic in megabytes, which is the size of memory allocated for the topic.", - "type": "integer", - "format": "int64" - }, - "RequiresDuplicateDetection": { - "description": "A value indicating if this topic requires duplicate detection.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "Status": { - "$ref": "#/definitions/EntityStatus" - }, - "SupportOrdering": { - "description": "A value that indicates whether the topic supports ordering.", - "type": "boolean", - "xml": { - "namespace": "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - } - }, - "UserMetadata": { - "description": "Metadata associated with the topic.", - "type": "string" - } - } - } - }, - "responses": { - "ServiceBusManagementErrorResponse": { - "description": "An error occurred. The possible HTTP status, code, and message strings are listed below", - "headers": { - "x-ms-request-id": { - "description": "A server-generated UUID recorded in the analytics logs for troubleshooting and correlation.", - "pattern": "^[{(]?[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}[)}]?$", - "type": "string" - }, - "x-ms-version": { - "description": "The version of the REST protocol used to process the request.", - "type": "string" - } - }, - "schema": { - "$ref": "#/definitions/ServiceBusManagementError" - } - } - }, - "paths": { - "/{queueName}": { - "parameters": [ - { - "name": "queueName", - "in": "path", - "description": "The name of the queue relative to the Service Bus namespace.", - "minLength": 1, - "x-ms-parameter-location": "method", - "required": true, - "type": "string" - } - ], - "get": { - "operationId": "Queue_Get", - "summary": "Get Queue", - "description": "Get the details about the Queue with the given queueName.", - "tags": [ - "Queue Operations" - ], - "parameters": [ - { - "$ref": "#/parameters/Enrich" - }, - { - "$ref": "#/parameters/ApiVersion" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - }, - "put": { - "tags": [ - "Queue Operations" - ], - "operationId": "Queue_Put", - "description": "Create or update a queue at the provided queuePath", - "parameters": [ - { - "name": "requestBody", - "in": "body", - "schema": { - "type": "object" - }, - "required": true, - "description": "Parameters required to make or edit a queue.", - "x-ms-parameter-location": "method" - }, - { - "$ref": "#/parameters/ApiVersion" - }, - { - "name": "If-Match", - "in": "header", - "required": false, - "type": "string", - "description": "Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, an insert will be performed when no existing entity is found to update and a replace will be performed if an existing entity is found.", - "x-ms-parameter-location": "method" - } - ], - "responses": { - "200": { - "description": "Update -- Update Queue operation completed successfully.", - "schema": { - "type": "object" - } - }, - "201": { - "description": "Created -- Create Queue operation completed successfully.", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - }, - "delete": { - "operationId": "Queue_Delete", - "summary": "Delete Queue", - "description": "Delete the Queue with the given queueName.", - "tags": [ - "Queue Operations" - ], - "parameters": [ - { - "$ref": "#/parameters/ApiVersion" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - } - }, - "/$Resources/{entityType}": { - "parameters": [ - { - "name": "entityType", - "in": "path", - "description": "List all queues or all topics of the service bus. Value can be \"queues\" or \"topics\" ", - "minLength": 1, - "x-ms-parameter-location": "method", - "required": true, - "type": "string" - } - ], - "get": { - "operationId": "listEntities", - "summary": "Get Queues or topics", - "description": "Get the details about the entities of the given Service Bus namespace.", - "tags": [ - "Queue Operations", - "Topic Operations" - ], - "parameters": [ - { - "name": "$skip", - "type": "integer", - "in": "query", - "default": 0 - }, - { - "name": "$top", - "type": "integer", - "in": "query", - "default": 100 - }, - { - "$ref": "#/parameters/ApiVersion" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "object" - } - }, - "default": { - "$ref": "#/responses/ServiceBusManagementErrorResponse" - } - } - } - } - } -} \ No newline at end of file diff --git a/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py b/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py index 43d8df894857..daee710d6b73 100644 --- a/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py +++ b/tools/azure-sdk-tools/devtools_testutils/resource_testcase.py @@ -6,6 +6,7 @@ from collections import namedtuple import functools import os +import datetime from functools import partial from azure_devtools.scenario_tests import AzureTestError, ReservedResourceNameError @@ -33,7 +34,8 @@ def __init__(self, name_prefix='', parameter_name_for_location='location', location='westus', disable_recording=True, playback_fake_resource=None, client_kwargs=None, - random_name_enabled=False): + random_name_enabled=False, + delete_after_tag_timedelta=datetime.timedelta(days=1)): super(ResourceGroupPreparer, self).__init__(name_prefix, random_name_length, disable_recording=disable_recording, playback_fake_resource=playback_fake_resource, @@ -50,13 +52,18 @@ def __init__(self, name_prefix='', if self.random_name_enabled: self.resource_moniker = self.name_prefix + "rgname" self.set_cache(use_cache, parameter_name) + self.delete_after_tag_timedelta = delete_after_tag_timedelta def create_resource(self, name, **kwargs): if self.is_live and self._need_creation: self.client = self.create_mgmt_client(ResourceManagementClient) + parameters = {'location': self.location} + if self.delete_after_tag_timedelta: + expiry = datetime.datetime.utcnow() + self.delete_after_tag_timedelta + parameters['tags'] = {'DeleteAfter': expiry.isoformat()} try: self.resource = self.client.resource_groups.create_or_update( - name, {'location': self.location} + name, parameters ) except Exception as ex: if "ReservedResourceName" in str(ex): @@ -92,4 +99,4 @@ def remove_resource(self, name, **kwargs): pass RandomNameResourceGroupPreparer = partial(ResourceGroupPreparer, random_name_enabled=True) -CachedResourceGroupPreparer = functools.partial(ResourceGroupPreparer, use_cache=True, random_name_enabled=True) +CachedResourceGroupPreparer = partial(ResourceGroupPreparer, use_cache=True, random_name_enabled=True)