diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py index b73c8228f1d8..2285ddea6a73 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_container_registry_management_client.py @@ -275,10 +275,13 @@ def scope_maps(self): """Instance depends on the API version: * 2019-05-01-preview: :class:`ScopeMapsOperations` + * 2019-06-01-preview: :class:`ScopeMapsOperations` """ api_version = self._get_api_version('scope_maps') if api_version == '2019-05-01-preview': from .v2019_05_01_preview.operations import ScopeMapsOperations as OperationClass + elif api_version == '2019-06-01-preview': + from .v2019_06_01_preview.operations import ScopeMapsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -310,10 +313,13 @@ def tokens(self): """Instance depends on the API version: * 2019-05-01-preview: :class:`TokensOperations` + * 2019-06-01-preview: :class:`TokensOperations` """ api_version = self._get_api_version('tokens') if api_version == '2019-05-01-preview': from .v2019_05_01_preview.operations import TokensOperations as OperationClass + elif api_version == '2019-06-01-preview': + from .v2019_06_01_preview.operations import TokensOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py index 31c53d3d5d00..ef41c8030ce1 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/_container_registry_management_client.py @@ -19,6 +19,8 @@ from .operations import WebhooksOperations from .operations import RunsOperations from .operations import TasksOperations +from .operations import ScopeMapsOperations +from .operations import TokensOperations from . import models @@ -40,6 +42,10 @@ class ContainerRegistryManagementClient(SDKClient): :vartype runs: azure.mgmt.containerregistry.v2019_06_01_preview.operations.RunsOperations :ivar tasks: Tasks operations :vartype tasks: azure.mgmt.containerregistry.v2019_06_01_preview.operations.TasksOperations + :ivar scope_maps: ScopeMaps operations + :vartype scope_maps: azure.mgmt.containerregistry.v2019_06_01_preview.operations.ScopeMapsOperations + :ivar tokens: Tokens operations + :vartype tokens: azure.mgmt.containerregistry.v2019_06_01_preview.operations.TokensOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -71,3 +77,7 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.tasks = TasksOperations( self._client, self.config, self._serialize, self._deserialize) + self.scope_maps = ScopeMapsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.tokens = TokensOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py index dd5418527208..ab873ab347ee 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/__init__.py @@ -35,6 +35,8 @@ from ._models_py3 import FileTaskRunRequest from ._models_py3 import FileTaskStep from ._models_py3 import FileTaskStepUpdateParameters + from ._models_py3 import GenerateCredentialsParameters + from ._models_py3 import GenerateCredentialsResult from ._models_py3 import IdentityProperties from ._models_py3 import ImageDescriptor from ._models_py3 import ImageUpdateTrigger @@ -72,6 +74,8 @@ from ._models_py3 import RunGetLogResult from ._models_py3 import RunRequest from ._models_py3 import RunUpdateParameters + from ._models_py3 import ScopeMap + from ._models_py3 import ScopeMapUpdateParameters from ._models_py3 import SecretObject from ._models_py3 import SetValue from ._models_py3 import Sku @@ -83,7 +87,7 @@ from ._models_py3 import SourceTriggerUpdateParameters from ._models_py3 import SourceUpdateParameters from ._models_py3 import SourceUploadDefinition - from ._models_py3 import Status + from ._models_py3 import Status1 from ._models_py3 import StorageAccountProperties from ._models_py3 import Target from ._models_py3 import Task @@ -94,6 +98,11 @@ from ._models_py3 import TimerTrigger from ._models_py3 import TimerTriggerDescriptor from ._models_py3 import TimerTriggerUpdateParameters + from ._models_py3 import Token + from ._models_py3 import TokenCertificate + from ._models_py3 import TokenCredentialsProperties + from ._models_py3 import TokenPassword + from ._models_py3 import TokenUpdateParameters from ._models_py3 import TriggerProperties from ._models_py3 import TriggerUpdateParameters from ._models_py3 import TrustPolicy @@ -128,6 +137,8 @@ from ._models import FileTaskRunRequest from ._models import FileTaskStep from ._models import FileTaskStepUpdateParameters + from ._models import GenerateCredentialsParameters + from ._models import GenerateCredentialsResult from ._models import IdentityProperties from ._models import ImageDescriptor from ._models import ImageUpdateTrigger @@ -165,6 +176,8 @@ from ._models import RunGetLogResult from ._models import RunRequest from ._models import RunUpdateParameters + from ._models import ScopeMap + from ._models import ScopeMapUpdateParameters from ._models import SecretObject from ._models import SetValue from ._models import Sku @@ -176,7 +189,7 @@ from ._models import SourceTriggerUpdateParameters from ._models import SourceUpdateParameters from ._models import SourceUploadDefinition - from ._models import Status + from ._models import Status1 from ._models import StorageAccountProperties from ._models import Target from ._models import Task @@ -187,6 +200,11 @@ from ._models import TimerTrigger from ._models import TimerTriggerDescriptor from ._models import TimerTriggerUpdateParameters + from ._models import Token + from ._models import TokenCertificate + from ._models import TokenCredentialsProperties + from ._models import TokenPassword + from ._models import TokenUpdateParameters from ._models import TriggerProperties from ._models import TriggerUpdateParameters from ._models import TrustPolicy @@ -200,7 +218,9 @@ from ._paged_models import RegistryPaged from ._paged_models import ReplicationPaged from ._paged_models import RunPaged +from ._paged_models import ScopeMapPaged from ._paged_models import TaskPaged +from ._paged_models import TokenPaged from ._paged_models import WebhookPaged from ._container_registry_management_client_enums import ( ImportMode, @@ -231,6 +251,9 @@ UpdateTriggerPayloadType, SourceRegistryLoginMode, SecretObjectType, + TokenCertificateName, + TokenPasswordName, + Status, ) __all__ = [ @@ -259,6 +282,8 @@ 'FileTaskRunRequest', 'FileTaskStep', 'FileTaskStepUpdateParameters', + 'GenerateCredentialsParameters', + 'GenerateCredentialsResult', 'IdentityProperties', 'ImageDescriptor', 'ImageUpdateTrigger', @@ -296,6 +321,8 @@ 'RunGetLogResult', 'RunRequest', 'RunUpdateParameters', + 'ScopeMap', + 'ScopeMapUpdateParameters', 'SecretObject', 'SetValue', 'Sku', @@ -307,7 +334,7 @@ 'SourceTriggerUpdateParameters', 'SourceUpdateParameters', 'SourceUploadDefinition', - 'Status', + 'Status1', 'StorageAccountProperties', 'Target', 'Task', @@ -318,6 +345,11 @@ 'TimerTrigger', 'TimerTriggerDescriptor', 'TimerTriggerUpdateParameters', + 'Token', + 'TokenCertificate', + 'TokenCredentialsProperties', + 'TokenPassword', + 'TokenUpdateParameters', 'TriggerProperties', 'TriggerUpdateParameters', 'TrustPolicy', @@ -333,6 +365,8 @@ 'EventPaged', 'RunPaged', 'TaskPaged', + 'ScopeMapPaged', + 'TokenPaged', 'ImportMode', 'SkuName', 'SkuTier', @@ -361,4 +395,7 @@ 'UpdateTriggerPayloadType', 'SourceRegistryLoginMode', 'SecretObjectType', + 'TokenCertificateName', + 'TokenPasswordName', + 'Status', ] diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py index adfdac7592d4..01a9df47ac51 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_container_registry_management_client_enums.py @@ -201,3 +201,21 @@ class SecretObjectType(str, Enum): opaque = "Opaque" vaultsecret = "Vaultsecret" + + +class TokenCertificateName(str, Enum): + + certificate1 = "certificate1" + certificate2 = "certificate2" + + +class TokenPasswordName(str, Enum): + + password1 = "password1" + password2 = "password2" + + +class Status(str, Enum): + + enabled = "enabled" + disabled = "disabled" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models.py index 3953308562d2..ee78a066af70 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models.py @@ -1223,6 +1223,58 @@ def __init__(self, **kwargs): self.type = 'FileTask' +class GenerateCredentialsParameters(Model): + """The parameters used to generate credentials for a specified token or user + of a container registry. + + :param token_id: The resource ID of the token for which credentials have + to be generated. + :type token_id: str + :param expiry: The expiry date of the generated credentials after which + the credentials become invalid. Default value: + "9999-12-31T15:59:59.9999999-08:00" . + :type expiry: datetime + :param name: Specifies name of the password which should be regenerated if + any -- password or password2. Possible values include: 'password1', + 'password2' + :type name: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPasswordName + """ + + _attribute_map = { + 'token_id': {'key': 'tokenId', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(GenerateCredentialsParameters, self).__init__(**kwargs) + self.token_id = kwargs.get('token_id', None) + self.expiry = kwargs.get('expiry', "9999-12-31T15:59:59.9999999-08:00") + self.name = kwargs.get('name', None) + + +class GenerateCredentialsResult(Model): + """The response from the GenerateCredentials operation. + + :param username: The username for a container registry. + :type username: str + :param passwords: The list of passwords for a container registry. + :type passwords: + list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPassword] + """ + + _attribute_map = { + 'username': {'key': 'username', 'type': 'str'}, + 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + } + + def __init__(self, **kwargs): + super(GenerateCredentialsResult, self).__init__(**kwargs) + self.username = kwargs.get('username', None) + self.passwords = kwargs.get('passwords', None) + + class IdentityProperties(Model): """Managed identity for the resource. @@ -1893,7 +1945,7 @@ class Registry(Resource): :ivar status: The status of the container registry at the time the operation was called. :vartype status: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status1 :param admin_user_enabled: The value that indicates whether the admin user is enabled. Default value: False . :type admin_user_enabled: bool @@ -1931,7 +1983,7 @@ class Registry(Resource): 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, + 'status': {'key': 'properties.status', 'type': 'Status1'}, 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountProperties'}, 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, @@ -2163,7 +2215,7 @@ class Replication(Resource): :ivar status: The status of the replication at the time the operation was called. :vartype status: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status1 """ _validation = { @@ -2182,7 +2234,7 @@ class Replication(Resource): 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, + 'status': {'key': 'properties.status', 'type': 'Status1'}, } def __init__(self, **kwargs): @@ -2494,6 +2546,90 @@ def __init__(self, **kwargs): self.is_archive_enabled = kwargs.get('is_archive_enabled', None) +class ScopeMap(ProxyResource): + """An object that represents a scope map for a container registry. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param description: The user friendly description of the scope map. + :type description: str + :ivar scope_map_type: The type of the scope map. E.g. BuildIn scope map. + :vartype scope_map_type: str + :ivar creation_date: The creation date of scope map. + :vartype creation_date: datetime + :ivar provisioning_state: Provisioning state of the resource. Possible + values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + 'Canceled' + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState + :param actions: Required. The list of scoped permissions for registry + artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete + :type actions: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'scope_map_type': {'readonly': True}, + 'creation_date': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'actions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'scope_map_type': {'key': 'properties.type', 'type': 'str'}, + 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'actions': {'key': 'properties.actions', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ScopeMap, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.scope_map_type = None + self.creation_date = None + self.provisioning_state = None + self.actions = kwargs.get('actions', None) + + +class ScopeMapUpdateParameters(Model): + """The properties for updating the scope map. + + :param description: The user friendly description of the scope map. + :type description: str + :param actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete + :type actions: list[str] + """ + + _attribute_map = { + 'description': {'key': 'properties.description', 'type': 'str'}, + 'actions': {'key': 'properties.actions', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ScopeMapUpdateParameters, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.actions = kwargs.get('actions', None) + + class SecretObject(Model): """Describes the properties of a secret object value. @@ -2852,7 +2988,7 @@ def __init__(self, **kwargs): self.relative_path = kwargs.get('relative_path', None) -class Status(Model): +class Status1(Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when @@ -2881,7 +3017,7 @@ class Status(Model): } def __init__(self, **kwargs): - super(Status, self).__init__(**kwargs) + super(Status1, self).__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None @@ -3239,6 +3375,191 @@ def __init__(self, **kwargs): self.name = kwargs.get('name', None) +class Token(ProxyResource): + """An object that represents a token for a container registry. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar creation_date: The creation date of scope map. + :vartype creation_date: datetime + :ivar provisioning_state: Provisioning state of the resource. Possible + values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + 'Canceled' + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState + :param scope_map_id: The resource ID of the scope map to which the token + will be associated with. + :type scope_map_id: str + :param object_id: The user/group/application object ID for which the token + has to be created. + :type object_id: str + :param credentials: The credentials that can be used for authenticating + the token. + :type credentials: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCredentialsProperties + :param status: The status of the token example enabled or disabled. + Possible values include: 'enabled', 'disabled' + :type status: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_date': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, + 'object_id': {'key': 'properties.objectId', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Token, self).__init__(**kwargs) + self.creation_date = None + self.provisioning_state = None + self.scope_map_id = kwargs.get('scope_map_id', None) + self.object_id = kwargs.get('object_id', None) + self.credentials = kwargs.get('credentials', None) + self.status = kwargs.get('status', None) + + +class TokenCertificate(Model): + """The properties of a certificate used for authenticating a token. + + :param name: Possible values include: 'certificate1', 'certificate2' + :type name: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCertificateName + :param expiry: The expiry datetime of the certificate. + :type expiry: datetime + :param thumbprint: The thumbprint of the certificate. + :type thumbprint: str + :param encoded_pem_certificate: Base 64 encoded string of the public + certificate1 in PEM format that will be used for authenticating the token. + :type encoded_pem_certificate: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(TokenCertificate, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.expiry = kwargs.get('expiry', None) + self.thumbprint = kwargs.get('thumbprint', None) + self.encoded_pem_certificate = kwargs.get('encoded_pem_certificate', None) + + +class TokenCredentialsProperties(Model): + """The properties of the credentials that can be used for authenticating the + token. + + :param certificates: + :type certificates: + list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCertificate] + :param passwords: + :type passwords: + list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPassword] + """ + + _attribute_map = { + 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, + 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + } + + def __init__(self, **kwargs): + super(TokenCredentialsProperties, self).__init__(**kwargs) + self.certificates = kwargs.get('certificates', None) + self.passwords = kwargs.get('passwords', None) + + +class TokenPassword(Model): + """The password that will be used for authenticating the token of a container + registry. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param creation_time: The password created datetime of the password. + :type creation_time: datetime + :param expiry: The expiry datetime of the password. + :type expiry: datetime + :param name: The password name "password" or "password2". Possible values + include: 'password1', 'password2' + :type name: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPasswordName + :ivar value: The password value. + :vartype value: str + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(TokenPassword, self).__init__(**kwargs) + self.creation_time = kwargs.get('creation_time', None) + self.expiry = kwargs.get('expiry', None) + self.name = kwargs.get('name', None) + self.value = None + + +class TokenUpdateParameters(Model): + """The parameters for updating a token. + + :param scope_map_id: The resource ID of the scope map to which the token + will be associated with. + :type scope_map_id: str + :param status: The status of the token example enabled or disabled. + Possible values include: 'enabled', 'disabled' + :type status: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + :param credentials: The credentials that can be used for authenticating + the token. + :type credentials: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCredentialsProperties + """ + + _attribute_map = { + 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + } + + def __init__(self, **kwargs): + super(TokenUpdateParameters, self).__init__(**kwargs) + self.scope_map_id = kwargs.get('scope_map_id', None) + self.status = kwargs.get('status', None) + self.credentials = kwargs.get('credentials', None) + + class TriggerProperties(Model): """The properties of a trigger. diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py index 254afe333ad5..18f9d93dcf5a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_models_py3.py @@ -1223,6 +1223,58 @@ def __init__(self, *, context_path: str=None, context_access_token: str=None, ta self.type = 'FileTask' +class GenerateCredentialsParameters(Model): + """The parameters used to generate credentials for a specified token or user + of a container registry. + + :param token_id: The resource ID of the token for which credentials have + to be generated. + :type token_id: str + :param expiry: The expiry date of the generated credentials after which + the credentials become invalid. Default value: + "9999-12-31T15:59:59.9999999-08:00" . + :type expiry: datetime + :param name: Specifies name of the password which should be regenerated if + any -- password or password2. Possible values include: 'password1', + 'password2' + :type name: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPasswordName + """ + + _attribute_map = { + 'token_id': {'key': 'tokenId', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, *, token_id: str=None, expiry="9999-12-31T15:59:59.9999999-08:00", name=None, **kwargs) -> None: + super(GenerateCredentialsParameters, self).__init__(**kwargs) + self.token_id = token_id + self.expiry = expiry + self.name = name + + +class GenerateCredentialsResult(Model): + """The response from the GenerateCredentials operation. + + :param username: The username for a container registry. + :type username: str + :param passwords: The list of passwords for a container registry. + :type passwords: + list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPassword] + """ + + _attribute_map = { + 'username': {'key': 'username', 'type': 'str'}, + 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + } + + def __init__(self, *, username: str=None, passwords=None, **kwargs) -> None: + super(GenerateCredentialsResult, self).__init__(**kwargs) + self.username = username + self.passwords = passwords + + class IdentityProperties(Model): """Managed identity for the resource. @@ -1893,7 +1945,7 @@ class Registry(Resource): :ivar status: The status of the container registry at the time the operation was called. :vartype status: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status1 :param admin_user_enabled: The value that indicates whether the admin user is enabled. Default value: False . :type admin_user_enabled: bool @@ -1931,7 +1983,7 @@ class Registry(Resource): 'login_server': {'key': 'properties.loginServer', 'type': 'str'}, 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, + 'status': {'key': 'properties.status', 'type': 'Status1'}, 'admin_user_enabled': {'key': 'properties.adminUserEnabled', 'type': 'bool'}, 'storage_account': {'key': 'properties.storageAccount', 'type': 'StorageAccountProperties'}, 'network_rule_set': {'key': 'properties.networkRuleSet', 'type': 'NetworkRuleSet'}, @@ -2163,7 +2215,7 @@ class Replication(Resource): :ivar status: The status of the replication at the time the operation was called. :vartype status: - ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status1 """ _validation = { @@ -2182,7 +2234,7 @@ class Replication(Resource): 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'Status'}, + 'status': {'key': 'properties.status', 'type': 'Status1'}, } def __init__(self, *, location: str, tags=None, **kwargs) -> None: @@ -2494,6 +2546,90 @@ def __init__(self, *, is_archive_enabled: bool=None, **kwargs) -> None: self.is_archive_enabled = is_archive_enabled +class ScopeMap(ProxyResource): + """An object that represents a scope map for a container registry. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param description: The user friendly description of the scope map. + :type description: str + :ivar scope_map_type: The type of the scope map. E.g. BuildIn scope map. + :vartype scope_map_type: str + :ivar creation_date: The creation date of scope map. + :vartype creation_date: datetime + :ivar provisioning_state: Provisioning state of the resource. Possible + values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + 'Canceled' + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState + :param actions: Required. The list of scoped permissions for registry + artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete + :type actions: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'scope_map_type': {'readonly': True}, + 'creation_date': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'actions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'scope_map_type': {'key': 'properties.type', 'type': 'str'}, + 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'actions': {'key': 'properties.actions', 'type': '[str]'}, + } + + def __init__(self, *, actions, description: str=None, **kwargs) -> None: + super(ScopeMap, self).__init__(**kwargs) + self.description = description + self.scope_map_type = None + self.creation_date = None + self.provisioning_state = None + self.actions = actions + + +class ScopeMapUpdateParameters(Model): + """The properties for updating the scope map. + + :param description: The user friendly description of the scope map. + :type description: str + :param actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete + :type actions: list[str] + """ + + _attribute_map = { + 'description': {'key': 'properties.description', 'type': 'str'}, + 'actions': {'key': 'properties.actions', 'type': '[str]'}, + } + + def __init__(self, *, description: str=None, actions=None, **kwargs) -> None: + super(ScopeMapUpdateParameters, self).__init__(**kwargs) + self.description = description + self.actions = actions + + class SecretObject(Model): """Describes the properties of a secret object value. @@ -2852,7 +2988,7 @@ def __init__(self, *, upload_url: str=None, relative_path: str=None, **kwargs) - self.relative_path = relative_path -class Status(Model): +class Status1(Model): """The status of an Azure resource at the time the operation was called. Variables are only populated by the server, and will be ignored when @@ -2881,7 +3017,7 @@ class Status(Model): } def __init__(self, **kwargs) -> None: - super(Status, self).__init__(**kwargs) + super(Status1, self).__init__(**kwargs) self.display_status = None self.message = None self.timestamp = None @@ -3239,6 +3375,191 @@ def __init__(self, *, name: str, schedule: str=None, status="Enabled", **kwargs) self.name = name +class Token(ProxyResource): + """An object that represents a token for a container registry. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :ivar creation_date: The creation date of scope map. + :vartype creation_date: datetime + :ivar provisioning_state: Provisioning state of the resource. Possible + values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', + 'Canceled' + :vartype provisioning_state: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ProvisioningState + :param scope_map_id: The resource ID of the scope map to which the token + will be associated with. + :type scope_map_id: str + :param object_id: The user/group/application object ID for which the token + has to be created. + :type object_id: str + :param credentials: The credentials that can be used for authenticating + the token. + :type credentials: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCredentialsProperties + :param status: The status of the token example enabled or disabled. + Possible values include: 'enabled', 'disabled' + :type status: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_date': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, + 'object_id': {'key': 'properties.objectId', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__(self, *, scope_map_id: str=None, object_id: str=None, credentials=None, status=None, **kwargs) -> None: + super(Token, self).__init__(**kwargs) + self.creation_date = None + self.provisioning_state = None + self.scope_map_id = scope_map_id + self.object_id = object_id + self.credentials = credentials + self.status = status + + +class TokenCertificate(Model): + """The properties of a certificate used for authenticating a token. + + :param name: Possible values include: 'certificate1', 'certificate2' + :type name: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCertificateName + :param expiry: The expiry datetime of the certificate. + :type expiry: datetime + :param thumbprint: The thumbprint of the certificate. + :type thumbprint: str + :param encoded_pem_certificate: Base 64 encoded string of the public + certificate1 in PEM format that will be used for authenticating the token. + :type encoded_pem_certificate: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, + 'encoded_pem_certificate': {'key': 'encodedPemCertificate', 'type': 'str'}, + } + + def __init__(self, *, name=None, expiry=None, thumbprint: str=None, encoded_pem_certificate: str=None, **kwargs) -> None: + super(TokenCertificate, self).__init__(**kwargs) + self.name = name + self.expiry = expiry + self.thumbprint = thumbprint + self.encoded_pem_certificate = encoded_pem_certificate + + +class TokenCredentialsProperties(Model): + """The properties of the credentials that can be used for authenticating the + token. + + :param certificates: + :type certificates: + list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCertificate] + :param passwords: + :type passwords: + list[~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPassword] + """ + + _attribute_map = { + 'certificates': {'key': 'certificates', 'type': '[TokenCertificate]'}, + 'passwords': {'key': 'passwords', 'type': '[TokenPassword]'}, + } + + def __init__(self, *, certificates=None, passwords=None, **kwargs) -> None: + super(TokenCredentialsProperties, self).__init__(**kwargs) + self.certificates = certificates + self.passwords = passwords + + +class TokenPassword(Model): + """The password that will be used for authenticating the token of a container + registry. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param creation_time: The password created datetime of the password. + :type creation_time: datetime + :param expiry: The expiry datetime of the password. + :type expiry: datetime + :param name: The password name "password" or "password2". Possible values + include: 'password1', 'password2' + :type name: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPasswordName + :ivar value: The password value. + :vartype value: str + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, *, creation_time=None, expiry=None, name=None, **kwargs) -> None: + super(TokenPassword, self).__init__(**kwargs) + self.creation_time = creation_time + self.expiry = expiry + self.name = name + self.value = None + + +class TokenUpdateParameters(Model): + """The parameters for updating a token. + + :param scope_map_id: The resource ID of the scope map to which the token + will be associated with. + :type scope_map_id: str + :param status: The status of the token example enabled or disabled. + Possible values include: 'enabled', 'disabled' + :type status: str or + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Status + :param credentials: The credentials that can be used for authenticating + the token. + :type credentials: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenCredentialsProperties + """ + + _attribute_map = { + 'scope_map_id': {'key': 'properties.scopeMapId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': 'TokenCredentialsProperties'}, + } + + def __init__(self, *, scope_map_id: str=None, status=None, credentials=None, **kwargs) -> None: + super(TokenUpdateParameters, self).__init__(**kwargs) + self.scope_map_id = scope_map_id + self.status = status + self.credentials = credentials + + class TriggerProperties(Model): """The properties of a trigger. diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_paged_models.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_paged_models.py index fdec95712a63..b91aff5d1e12 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_paged_models.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/models/_paged_models.py @@ -103,3 +103,29 @@ class TaskPaged(Paged): def __init__(self, *args, **kwargs): super(TaskPaged, self).__init__(*args, **kwargs) +class ScopeMapPaged(Paged): + """ + A paging container for iterating over a list of :class:`ScopeMap ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ScopeMap]'} + } + + def __init__(self, *args, **kwargs): + + super(ScopeMapPaged, self).__init__(*args, **kwargs) +class TokenPaged(Paged): + """ + A paging container for iterating over a list of :class:`Token ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Token]'} + } + + def __init__(self, *args, **kwargs): + + super(TokenPaged, self).__init__(*args, **kwargs) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py index b05c49580519..d50454ded73d 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/__init__.py @@ -15,6 +15,8 @@ from ._webhooks_operations import WebhooksOperations from ._runs_operations import RunsOperations from ._tasks_operations import TasksOperations +from ._scope_maps_operations import ScopeMapsOperations +from ._tokens_operations import TokensOperations __all__ = [ 'RegistriesOperations', @@ -23,4 +25,6 @@ 'WebhooksOperations', 'RunsOperations', 'TasksOperations', + 'ScopeMapsOperations', + 'TokensOperations', ] diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py index 1e5eb58e37fe..25396f418919 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_registries_operations.py @@ -1077,3 +1077,109 @@ def get_build_source_upload_url( return deserialized get_build_source_upload_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl'} + + + def _generate_credentials_initial( + self, resource_group_name, registry_name, generate_credentials_parameters, custom_headers=None, raw=False, **operation_config): + api_version = "2019-05-01-preview" + + # Construct URL + url = self.generate_credentials.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(generate_credentials_parameters, 'GenerateCredentialsParameters') + + # 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, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('GenerateCredentialsResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def generate_credentials( + self, resource_group_name, registry_name, generate_credentials_parameters, custom_headers=None, raw=False, polling=True, **operation_config): + """Generate keys for a token of a specified container registry. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param generate_credentials_parameters: The parameters for generating + credentials. + :type generate_credentials_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.GenerateCredentialsParameters + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns + GenerateCredentialsResult or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.GenerateCredentialsResult] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.containerregistry.v2019_06_01_preview.models.GenerateCredentialsResult]] + :raises: :class:`CloudError` + """ + raw_result = self._generate_credentials_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + generate_credentials_parameters=generate_credentials_parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('GenerateCredentialsResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + generate_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials'} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_scope_maps_operations.py new file mode 100644 index 000000000000..f7426a43de4b --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_scope_maps_operations.py @@ -0,0 +1,494 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class ScopeMapsOperations(object): + """ScopeMapsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The client API version. Constant value: "2019-05-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-05-01-preview" + + self.config = config + + def get( + self, resource_group_name, registry_name, scope_map_name, custom_headers=None, raw=False, **operation_config): + """Gets the properties of the specified scope map. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param scope_map_name: The name of the scope map. + :type scope_map_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 + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ScopeMap or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMap or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'scopeMapName': self._serialize.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # 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]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ScopeMap', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}'} + + + def _create_initial( + self, resource_group_name, registry_name, scope_map_name, actions, description=None, custom_headers=None, raw=False, **operation_config): + scope_map_create_parameters = models.ScopeMap(description=description, actions=actions) + + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'scopeMapName': self._serialize.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(scope_map_create_parameters, 'ScopeMap') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ScopeMap', response) + if response.status_code == 201: + deserialized = self._deserialize('ScopeMap', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create( + self, resource_group_name, registry_name, scope_map_name, actions, description=None, custom_headers=None, raw=False, polling=True, **operation_config): + """Creates a scope map for a container registry with the specified + parameters. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param scope_map_name: The name of the scope map. + :type scope_map_name: str + :param actions: The list of scoped permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete + :type actions: list[str] + :param description: The user friendly description of the scope map. + :type description: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns ScopeMap or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMap] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMap]] + :raises: :class:`CloudError` + """ + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + actions=actions, + description=description, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('ScopeMap', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}'} + + + def _delete_initial( + self, resource_group_name, registry_name, scope_map_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'scopeMapName': self._serialize.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def delete( + self, resource_group_name, registry_name, scope_map_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes a scope map from a container registry. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param scope_map_name: The name of the scope map. + :type scope_map_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}'} + + + def _update_initial( + self, resource_group_name, registry_name, scope_map_name, description=None, actions=None, custom_headers=None, raw=False, **operation_config): + scope_map_update_parameters = models.ScopeMapUpdateParameters(description=description, actions=actions) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'scopeMapName': self._serialize.url("scope_map_name", scope_map_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(scope_map_update_parameters, 'ScopeMapUpdateParameters') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ScopeMap', response) + if response.status_code == 201: + deserialized = self._deserialize('ScopeMap', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, registry_name, scope_map_name, description=None, actions=None, custom_headers=None, raw=False, polling=True, **operation_config): + """Updates a scope map with the specified parameters. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param scope_map_name: The name of the scope map. + :type scope_map_name: str + :param description: The user friendly description of the scope map. + :type description: str + :param actions: The list of scope permissions for registry artifacts. + E.g. repositories/repository-name/pull, + repositories/repository-name/delete + :type actions: list[str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns ScopeMap or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMap] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMap]] + :raises: :class:`CloudError` + """ + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + scope_map_name=scope_map_name, + description=description, + actions=actions, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('ScopeMap', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}'} + + def list( + self, resource_group_name, registry_name, custom_headers=None, raw=False, **operation_config): + """Lists all the scope maps for the specified container registry. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_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 + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ScopeMap + :rtype: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMapPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.ScopeMap] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ScopeMapPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps'} diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tokens_operations.py new file mode 100644 index 000000000000..0275bad8813a --- /dev/null +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tokens_operations.py @@ -0,0 +1,480 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class TokensOperations(object): + """TokensOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The client API version. Constant value: "2019-05-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-05-01-preview" + + self.config = config + + def get( + self, resource_group_name, registry_name, token_name, custom_headers=None, raw=False, **operation_config): + """Gets the properties of the specified token. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param token_name: The name of the token. + :type token_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 + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Token or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'tokenName': self._serialize.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # 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]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Token', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}'} + + + def _create_initial( + self, resource_group_name, registry_name, token_name, token_create_parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'tokenName': self._serialize.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(token_create_parameters, 'Token') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Token', response) + if response.status_code == 201: + deserialized = self._deserialize('Token', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create( + self, resource_group_name, registry_name, token_name, token_create_parameters, custom_headers=None, raw=False, polling=True, **operation_config): + """Creates a token for a container registry with the specified parameters. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param token_name: The name of the token. + :type token_name: str + :param token_create_parameters: The parameters for creating a token. + :type token_create_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Token or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token]] + :raises: :class:`CloudError` + """ + raw_result = self._create_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_create_parameters=token_create_parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Token', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}'} + + + def _delete_initial( + self, resource_group_name, registry_name, token_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'tokenName': self._serialize.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def delete( + self, resource_group_name, registry_name, token_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes a token from a container registry. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param token_name: The name of the token. + :type token_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}'} + + + def _update_initial( + self, resource_group_name, registry_name, token_name, token_update_parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$'), + 'tokenName': self._serialize.url("token_name", token_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9-]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(token_update_parameters, 'TokenUpdateParameters') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Token', response) + if response.status_code == 201: + deserialized = self._deserialize('Token', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, registry_name, token_name, token_update_parameters, custom_headers=None, raw=False, polling=True, **operation_config): + """Updates a token with the specified parameters. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_name: str + :param token_name: The name of the token. + :type token_name: str + :param token_update_parameters: The parameters for updating a token. + :type token_update_parameters: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenUpdateParameters + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Token or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token]] + :raises: :class:`CloudError` + """ + raw_result = self._update_initial( + resource_group_name=resource_group_name, + registry_name=registry_name, + token_name=token_name, + token_update_parameters=token_update_parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Token', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}'} + + def list( + self, resource_group_name, registry_name, custom_headers=None, raw=False, **operation_config): + """Lists all the tokens for the specified container registry. + + :param resource_group_name: The name of the resource group to which + the container registry belongs. + :type resource_group_name: str + :param registry_name: The name of the container registry. + :type registry_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 + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Token + :rtype: + ~azure.mgmt.containerregistry.v2019_06_01_preview.models.TokenPaged[~azure.mgmt.containerregistry.v2019_06_01_preview.models.Token] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', min_length=1), + 'registryName': self._serialize.url("registry_name", registry_name, 'str', max_length=50, min_length=5, pattern=r'^[a-zA-Z0-9]*$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.TokenPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens'}