def replicate_vm_image(self, vm_image_name, regions, offer, sku, version):
        '''
        Replicate a VM image to multiple target locations. This operation
        is only for publishers. You have to be registered as image publisher
        with Microsoft Azure to be able to call this.

        vm_image_name:
            Specifies the name of the VM Image that is to be used for
            replication
        regions:
            Specified a list of regions to replicate the image to
            Note: The regions in the request body are not additive. If a VM
            Image has already been replicated to Regions A, B, and C, and
            a request is made to replicate to Regions A and D, the VM
            Image will remain in Region A, will be replicated in Region D,
            and will be unreplicated from Regions B and C
        offer:
            Specifies the publisher defined name of the offer. The allowed
            characters are uppercase or lowercase letters, digit,
            hypen(-), period (.).The maximum allowed length is 64 characters.
        sku:
            Specifies the publisher defined name of the Sku. The allowed
            characters are uppercase or lowercase letters, digit,
            hypen(-), period (.). The maximum allowed length is 64 characters.
        version:
            Specifies the publisher defined version of the image.
            The allowed characters are digit and period.
            Format: <MajorVersion>.<MinorVersion>.<Patch>
            Example: '1.0.0' or '1.1.0' The 3 version number to
            follow standard of most of the RPs. See http://semver.org
        '''
        _validate_not_none('vm_image_name', vm_image_name)
        _validate_not_none('regions', regions)
        _validate_not_none('offer', offer)
        _validate_not_none('sku', sku)
        _validate_not_none('version', version)

        return self._perform_put(
            self._get_replication_path_using_vm_image_name(vm_image_name),
            _XmlSerializer.replicate_image_to_xml(
                regions,
                offer,
                sku,
                version
            ),
            as_async=True,
            x_ms_version='2015-04-01'
        )

Replicate a VM image to multiple target locations . This operation is only for publishers . You have to be registered as image publisher with Microsoft Azure to be able to call this .


def unreplicate_vm_image(self, vm_image_name):
        '''
        Unreplicate a VM image from all regions This operation
        is only for publishers. You have to be registered as image publisher
        with Microsoft Azure to be able to call this

        vm_image_name:
            Specifies the name of the VM Image that is to be used for
            unreplication. The VM Image Name should be the user VM Image,
            not the published name of the VM Image.

        '''
        _validate_not_none('vm_image_name', vm_image_name)

        return self._perform_put(
            self._get_unreplication_path_using_vm_image_name(vm_image_name),
            None,
            as_async=True,
            x_ms_version='2015-04-01'
        )

Unreplicate a VM image from all regions This operation is only for publishers . You have to be registered as image publisher with Microsoft Azure to be able to call this


def share_vm_image(self, vm_image_name, permission):
        '''
        Share an already replicated OS image. This operation is only for
        publishers. You have to be registered as image publisher with Windows
        Azure to be able to call this.

        vm_image_name:
            The name of the virtual machine image to share
        permission:
            The sharing permission: public, msdn, or private
        '''
        _validate_not_none('vm_image_name', vm_image_name)
        _validate_not_none('permission', permission)

        path = self._get_sharing_path_using_vm_image_name(vm_image_name)
        query = '&permission=' + permission
        path = path + '?' + query.lstrip('&')

        return self._perform_put(
            path, None, as_async=True, x_ms_version='2015-04-01'
        )

def share_vm_image ( self , vm_image_name , permission ) : _validate_not_none ( 'vm_image_name' , vm_image_name ) _validate_not_none ( 'permission' , permission ) path = self . _get_sharing_path_using_vm_image_name ( vm_image_name ) query = '&permission=' + permission path = path + '?' + query . lstrip ( '&' ) return self . _perform_put ( path , None , as_async = True , x_ms_version = '2015-04-01' )

Share an already replicated OS image . This operation is only for publishers . You have to be registered as image publisher with Windows Azure to be able to call this .


def create_vm_image(self, vm_image):
        '''
        Creates a VM Image in the image repository that is associated with the
        specified subscription using a specified set of virtual hard disks.

        vm_image:
            An instance of VMImage class.
        vm_image.name: Required. Specifies the name of the image.
        vm_image.label: Required. Specifies an identifier for the image.
        vm_image.description: Optional. Specifies the description of the image.
        vm_image.os_disk_configuration:
            Required. Specifies configuration information for the operating
            system disk that is associated with the image.
        vm_image.os_disk_configuration.host_caching:
            Optional. Specifies the caching behavior of the operating system disk.
            Possible values are: None, ReadOnly, ReadWrite
        vm_image.os_disk_configuration.os_state:
            Required. Specifies the state of the operating system in the image.
            Possible values are: Generalized, Specialized
            A Virtual Machine that is fully configured and running contains a
            Specialized operating system. A Virtual Machine on which the
            Sysprep command has been run with the generalize option contains a
            Generalized operating system.
        vm_image.os_disk_configuration.os:
            Required. Specifies the operating system type of the image.
        vm_image.os_disk_configuration.media_link:
            Required. Specifies the location of the blob in Windows Azure
            storage. The blob location belongs to a storage account in the
            subscription specified by the <subscription-id> value in the
            operation call.
        vm_image.data_disk_configurations:
            Optional. Specifies configuration information for the data disks
            that are associated with the image. A VM Image might not have data
            disks associated with it.
        vm_image.data_disk_configurations[].host_caching:
            Optional. Specifies the caching behavior of the data disk.
            Possible values are: None, ReadOnly, ReadWrite
        vm_image.data_disk_configurations[].lun:
            Optional if the lun for the disk is 0. Specifies the Logical Unit
            Number (LUN) for the data disk.
        vm_image.data_disk_configurations[].media_link:
            Required. Specifies the location of the blob in Windows Azure
            storage. The blob location belongs to a storage account in the
            subscription specified by the <subscription-id> value in the
            operation call.
        vm_image.data_disk_configurations[].logical_size_in_gb:
            Required. Specifies the size, in GB, of the data disk.
        vm_image.language: Optional. Specifies the language of the image.
        vm_image.image_family:
            Optional. Specifies a value that can be used to group VM Images.
        vm_image.recommended_vm_size:
            Optional. Specifies the size to use for the Virtual Machine that
            is created from the VM Image.
        vm_image.eula:
            Optional. Specifies the End User License Agreement that is
            associated with the image. The value for this element is a string,
            but it is recommended that the value be a URL that points to a EULA.
        vm_image.icon_uri:
            Optional. Specifies the URI to the icon that is displayed for the
            image in the Management Portal.
        vm_image.small_icon_uri:
            Optional. Specifies the URI to the small icon that is displayed for
            the image in the Management Portal.
        vm_image.privacy_uri:
            Optional. Specifies the URI that points to a document that contains
            the privacy policy related to the image.
        vm_image.published_date:
            Optional. Specifies the date when the image was added to the image
            repository.
        vm_image.show_in_gui:
            Optional. Indicates whether the VM Images should be listed in the
            portal.
        '''
        _validate_not_none('vm_image', vm_image)
        _validate_not_none('vm_image.name', vm_image.name)
        _validate_not_none('vm_image.label', vm_image.label)
        _validate_not_none('vm_image.os_disk_configuration.os_state',
                           vm_image.os_disk_configuration.os_state)
        _validate_not_none('vm_image.os_disk_configuration.os',
                           vm_image.os_disk_configuration.os)
        _validate_not_none('vm_image.os_disk_configuration.media_link',
                           vm_image.os_disk_configuration.media_link)
        return self._perform_post(
            self._get_vm_image_path(),
            _XmlSerializer.create_vm_image_to_xml(vm_image),
            as_async=True)

Creates a VM Image in the image repository that is associated with the specified subscription using a specified set of virtual hard disks .


def delete_vm_image(self, vm_image_name, delete_vhd=False):
        '''
        Deletes the specified VM Image from the image repository that is
        associated with the specified subscription.

        vm_image_name:
            The name of the image.
        delete_vhd:
            Deletes the underlying vhd blob in Azure storage.
        '''
        _validate_not_none('vm_image_name', vm_image_name)
        path = self._get_vm_image_path(vm_image_name)
        if delete_vhd:
            path += '?comp=media'
        return self._perform_delete(path, as_async=True)

def delete_vm_image ( self , vm_image_name , delete_vhd = False ) : _validate_not_none ( 'vm_image_name' , vm_image_name ) path = self . _get_vm_image_path ( vm_image_name ) if delete_vhd : path += '?comp=media' return self . _perform_delete ( path , as_async = True )

Deletes the specified VM Image from the image repository that is associated with the specified subscription .


def list_vm_images(self, location=None, publisher=None, category=None):
        '''
        Retrieves a list of the VM Images from the image repository that is
        associated with the specified subscription.
        '''
        path = self._get_vm_image_path()
        query = ''
        if location:
            query += '&location=' + location
        if publisher:
            query += '&publisher=' + publisher
        if category:
            query += '&category=' + category
        if query:
            path = path + '?' + query.lstrip('&')
        return self._perform_get(path, VMImages)

def list_vm_images ( self , location = None , publisher = None , category = None ) : path = self . _get_vm_image_path ( ) query = '' if location : query += '&location=' + location if publisher : query += '&publisher=' + publisher if category : query += '&category=' + category if query : path = path + '?' + query . lstrip ( '&' ) return self . _perform_get ( path , VMImages )

Retrieves a list of the VM Images from the image repository that is associated with the specified subscription .


def update_vm_image(self, vm_image_name, vm_image):
        '''
        Updates a VM Image in the image repository that is associated with the
        specified subscription.

        vm_image_name:
            Name of image to update.
        vm_image:
            An instance of VMImage class.
        vm_image.label: Optional. Specifies an identifier for the image.
        vm_image.os_disk_configuration:
            Required. Specifies configuration information for the operating
            system disk that is associated with the image.
        vm_image.os_disk_configuration.host_caching:
            Optional. Specifies the caching behavior of the operating system disk.
            Possible values are: None, ReadOnly, ReadWrite
        vm_image.data_disk_configurations:
            Optional. Specifies configuration information for the data disks
            that are associated with the image. A VM Image might not have data
            disks associated with it.
        vm_image.data_disk_configurations[].name:
            Required. Specifies the name of the data disk.
        vm_image.data_disk_configurations[].host_caching:
            Optional. Specifies the caching behavior of the data disk.
            Possible values are: None, ReadOnly, ReadWrite
        vm_image.data_disk_configurations[].lun:
            Optional if the lun for the disk is 0. Specifies the Logical Unit
            Number (LUN) for the data disk.
        vm_image.description: Optional. Specifies the description of the image.
        vm_image.language: Optional. Specifies the language of the image.
        vm_image.image_family:
            Optional. Specifies a value that can be used to group VM Images.
        vm_image.recommended_vm_size:
            Optional. Specifies the size to use for the Virtual Machine that
            is created from the VM Image.
        vm_image.eula:
            Optional. Specifies the End User License Agreement that is
            associated with the image. The value for this element is a string,
            but it is recommended that the value be a URL that points to a EULA.
        vm_image.icon_uri:
            Optional. Specifies the URI to the icon that is displayed for the
            image in the Management Portal.
        vm_image.small_icon_uri:
            Optional. Specifies the URI to the small icon that is displayed for
            the image in the Management Portal.
        vm_image.privacy_uri:
            Optional. Specifies the URI that points to a document that contains
            the privacy policy related to the image.
        vm_image.published_date:
            Optional. Specifies the date when the image was added to the image
            repository.
        vm_image.show_in_gui:
            Optional. Indicates whether the VM Images should be listed in the
            portal.
        '''
        _validate_not_none('vm_image_name', vm_image_name)
        _validate_not_none('vm_image', vm_image)
        return self._perform_put(self._get_vm_image_path(vm_image_name),
                                 _XmlSerializer.update_vm_image_to_xml(vm_image),
                                 as_async=True)

Updates a VM Image in the image repository that is associated with the specified subscription .


def add_os_image(self, label, media_link, name, os):
        '''
        Adds an OS image that is currently stored in a storage account in your
        subscription to the image repository.

        label:
            Specifies the friendly name of the image.
        media_link:
            Specifies the location of the blob in Windows Azure blob store
            where the media for the image is located. The blob location must
            belong to a storage account in the subscription specified by the
            <subscription-id> value in the operation call. Example:
            http://example.blob.core.windows.net/disks/mydisk.vhd
        name:
            Specifies a name for the OS image that Windows Azure uses to
            identify the image when creating one or more virtual machines.
        os:
            The operating system type of the OS image. Possible values are:
            Linux, Windows
        '''
        _validate_not_none('label', label)
        _validate_not_none('media_link', media_link)
        _validate_not_none('name', name)
        _validate_not_none('os', os)
        return self._perform_post(self._get_image_path(),
                                  _XmlSerializer.os_image_to_xml(
                                      label, media_link, name, os),
                                  as_async=True)

def add_os_image ( self , label , media_link , name , os ) : _validate_not_none ( 'label' , label ) _validate_not_none ( 'media_link' , media_link ) _validate_not_none ( 'name' , name ) _validate_not_none ( 'os' , os ) return self . _perform_post ( self . _get_image_path ( ) , _XmlSerializer . os_image_to_xml ( label , media_link , name , os ) , as_async = True )

Adds an OS image that is currently stored in a storage account in your subscription to the image repository .


def update_os_image(self, image_name, label, media_link, name, os):
        '''
        Updates an OS image that in your image repository.

        image_name:
            The name of the image to update.
        label:
            Specifies the friendly name of the image to be updated. You cannot
            use this operation to update images provided by the Windows Azure
            platform.
        media_link:
            Specifies the location of the blob in Windows Azure blob store
            where the media for the image is located. The blob location must
            belong to a storage account in the subscription specified by the
            <subscription-id> value in the operation call. Example:
            http://example.blob.core.windows.net/disks/mydisk.vhd
        name:
            Specifies a name for the OS image that Windows Azure uses to
            identify the image when creating one or more VM Roles.
        os:
            The operating system type of the OS image. Possible values are:
            Linux, Windows
        '''
        _validate_not_none('image_name', image_name)
        _validate_not_none('label', label)
        _validate_not_none('media_link', media_link)
        _validate_not_none('name', name)
        _validate_not_none('os', os)
        return self._perform_put(self._get_image_path(image_name),
                                 _XmlSerializer.os_image_to_xml(
                                     label, media_link, name, os),
                                 as_async=True)

def update_os_image ( self , image_name , label , media_link , name , os ) : _validate_not_none ( 'image_name' , image_name ) _validate_not_none ( 'label' , label ) _validate_not_none ( 'media_link' , media_link ) _validate_not_none ( 'name' , name ) _validate_not_none ( 'os' , os ) return self . _perform_put ( self . _get_image_path ( image_name ) , _XmlSerializer . os_image_to_xml ( label , media_link , name , os ) , as_async = True )

Updates an OS image that in your image repository .


def update_os_image_from_image_reference(self, image_name, os_image):
        '''
        Updates metadata elements from a given OS image reference.

        image_name:
            The name of the image to update.
        os_image:
            An instance of OSImage class.
        os_image.label: Optional. Specifies an identifier for the image.
        os_image.description: Optional. Specifies the description of the image.
        os_image.language: Optional. Specifies the language of the image.
        os_image.image_family:
            Optional. Specifies a value that can be used to group VM Images.
        os_image.recommended_vm_size:
            Optional. Specifies the size to use for the Virtual Machine that
            is created from the VM Image.
        os_image.eula:
            Optional. Specifies the End User License Agreement that is
            associated with the image. The value for this element is a string,
            but it is recommended that the value be a URL that points to a EULA.
        os_image.icon_uri:
            Optional. Specifies the URI to the icon that is displayed for the
            image in the Management Portal.
        os_image.small_icon_uri:
            Optional. Specifies the URI to the small icon that is displayed for
            the image in the Management Portal.
        os_image.privacy_uri:
            Optional. Specifies the URI that points to a document that contains
            the privacy policy related to the image.
        os_image.published_date:
            Optional. Specifies the date when the image was added to the image
            repository.
        os.image.media_link:
            Required: Specifies the location of the blob in Windows Azure
            blob store where the media for the image is located. The blob
            location must belong to a storage account in the subscription
            specified by the <subscription-id> value in the operation call.
            Example:
            http://example.blob.core.windows.net/disks/mydisk.vhd
        os_image.name:
            Specifies a name for the OS image that Windows Azure uses to
            identify the image when creating one or more VM Roles.
        os_image.os:
            The operating system type of the OS image. Possible values are:
            Linux, Windows
        '''
        _validate_not_none('image_name', image_name)
        _validate_not_none('os_image', os_image)
        return self._perform_put(self._get_image_path(image_name),
            _XmlSerializer.update_os_image_to_xml(os_image), as_async=True
        )

Updates metadata elements from a given OS image reference .


def delete_os_image(self, image_name, delete_vhd=False):
        '''
        Deletes the specified OS image from your image repository.

        image_name:
            The name of the image.
        delete_vhd:
            Deletes the underlying vhd blob in Azure storage.
        '''
        _validate_not_none('image_name', image_name)
        path = self._get_image_path(image_name)
        if delete_vhd:
            path += '?comp=media'
        return self._perform_delete(path, as_async=True)

def delete_os_image ( self , image_name , delete_vhd = False ) : _validate_not_none ( 'image_name' , image_name ) path = self . _get_image_path ( image_name ) if delete_vhd : path += '?comp=media' return self . _perform_delete ( path , as_async = True )

Deletes the specified OS image from your image repository .


def get_data_disk(self, service_name, deployment_name, role_name, lun):
        '''
        Retrieves the specified data disk from a virtual machine.

        service_name:
            The name of the service.
        deployment_name:
            The name of the deployment.
        role_name:
            The name of the role.
        lun:
            The Logical Unit Number (LUN) for the disk.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('role_name', role_name)
        _validate_not_none('lun', lun)
        return self._perform_get(
            self._get_data_disk_path(
                service_name, deployment_name, role_name, lun),
            DataVirtualHardDisk)

def get_data_disk ( self , service_name , deployment_name , role_name , lun ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_name' , deployment_name ) _validate_not_none ( 'role_name' , role_name ) _validate_not_none ( 'lun' , lun ) return self . _perform_get ( self . _get_data_disk_path ( service_name , deployment_name , role_name , lun ) , DataVirtualHardDisk )

Retrieves the specified data disk from a virtual machine .


def add_data_disk(self, service_name, deployment_name, role_name, lun,
                      host_caching=None, media_link=None, disk_label=None,
                      disk_name=None, logical_disk_size_in_gb=None,
                      source_media_link=None):
        '''
        Adds a data disk to a virtual machine.

        service_name:
            The name of the service.
        deployment_name:
            The name of the deployment.
        role_name:
            The name of the role.
        lun:
            Specifies the Logical Unit Number (LUN) for the disk. The LUN
            specifies the slot in which the data drive appears when mounted
            for usage by the virtual machine. Valid LUN values are 0 through 15.
        host_caching:
            Specifies the platform caching behavior of data disk blob for
            read/write efficiency. The default vault is ReadOnly. Possible
            values are: None, ReadOnly, ReadWrite
        media_link:
            Specifies the location of the blob in Windows Azure blob store
            where the media for the disk is located. The blob location must
            belong to the storage account in the subscription specified by the
            <subscription-id> value in the operation call. Example:
            http://example.blob.core.windows.net/disks/mydisk.vhd
        disk_label:
            Specifies the description of the data disk. When you attach a disk,
            either by directly referencing a media using the MediaLink element
            or specifying the target disk size, you can use the DiskLabel
            element to customize the name property of the target data disk.
        disk_name:
            Specifies the name of the disk. Windows Azure uses the specified
            disk to create the data disk for the machine and populates this
            field with the disk name.
        logical_disk_size_in_gb:
            Specifies the size, in GB, of an empty disk to be attached to the
            role. The disk can be created as part of disk attach or create VM
            role call by specifying the value for this property. Windows Azure
            creates the empty disk based on size preference and attaches the
            newly created disk to the Role.
        source_media_link:
            Specifies the location of a blob in account storage which is
            mounted as a data disk when the virtual machine is created.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('role_name', role_name)
        _validate_not_none('lun', lun)
        return self._perform_post(
            self._get_data_disk_path(service_name, deployment_name, role_name),
            _XmlSerializer.data_virtual_hard_disk_to_xml(
                host_caching,
                disk_label,
                disk_name,
                lun,
                logical_disk_size_in_gb,
                media_link,
                source_media_link),
            as_async=True)


def update_data_disk(self, service_name, deployment_name, role_name, lun,
                         host_caching=None, media_link=None, updated_lun=None,
                         disk_label=None, disk_name=None,
                         logical_disk_size_in_gb=None):
        '''
        Updates the specified data disk attached to the specified virtual
        machine.

        service_name:
            The name of the service.
        deployment_name:
            The name of the deployment.
        role_name:
            The name of the role.
        lun:
            Specifies the Logical Unit Number (LUN) for the disk. The LUN
            specifies the slot in which the data drive appears when mounted
            for usage by the virtual machine. Valid LUN values are 0 through
            15.
        host_caching:
            Specifies the platform caching behavior of data disk blob for
            read/write efficiency. The default vault is ReadOnly. Possible
            values are: None, ReadOnly, ReadWrite
        media_link:
            Specifies the location of the blob in Windows Azure blob store
            where the media for the disk is located. The blob location must
            belong to the storage account in the subscription specified by
            the <subscription-id> value in the operation call. Example:
            http://example.blob.core.windows.net/disks/mydisk.vhd
        updated_lun:
            Specifies the Logical Unit Number (LUN) for the disk. The LUN
            specifies the slot in which the data drive appears when mounted
            for usage by the virtual machine. Valid LUN values are 0 through 15.
        disk_label:
            Specifies the description of the data disk. When you attach a disk,
            either by directly referencing a media using the MediaLink element
            or specifying the target disk size, you can use the DiskLabel
            element to customize the name property of the target data disk.
        disk_name:
            Specifies the name of the disk. Windows Azure uses the specified
            disk to create the data disk for the machine and populates this
            field with the disk name.
        logical_disk_size_in_gb:
            Specifies the size, in GB, of an empty disk to be attached to the
            role. The disk can be created as part of disk attach or create VM
            role call by specifying the value for this property. Windows Azure
            creates the empty disk based on size preference and attaches the
            newly created disk to the Role.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('role_name', role_name)
        _validate_not_none('lun', lun)
        return self._perform_put(
            self._get_data_disk_path(
                service_name, deployment_name, role_name, lun),
            _XmlSerializer.data_virtual_hard_disk_to_xml(
                host_caching,
                disk_label,
                disk_name,
                updated_lun,
                logical_disk_size_in_gb,
                media_link,
                None),
            as_async=True)

Updates the specified data disk attached to the specified virtual machine .


def delete_data_disk(self, service_name, deployment_name, role_name, lun, delete_vhd=False):
        '''
        Removes the specified data disk from a virtual machine.

        service_name:
            The name of the service.
        deployment_name:
            The name of the deployment.
        role_name:
            The name of the role.
        lun:
            The Logical Unit Number (LUN) for the disk.
        delete_vhd:
            Deletes the underlying vhd blob in Azure storage.
        '''
        _validate_not_none('service_name', service_name)
        _validate_not_none('deployment_name', deployment_name)
        _validate_not_none('role_name', role_name)
        _validate_not_none('lun', lun)
        path = self._get_data_disk_path(service_name, deployment_name, role_name, lun)
        if delete_vhd:
            path += '?comp=media'
        return self._perform_delete(path, as_async=True)

def delete_data_disk ( self , service_name , deployment_name , role_name , lun , delete_vhd = False ) : _validate_not_none ( 'service_name' , service_name ) _validate_not_none ( 'deployment_name' , deployment_name ) _validate_not_none ( 'role_name' , role_name ) _validate_not_none ( 'lun' , lun ) path = self . _get_data_disk_path ( service_name , deployment_name , role_name , lun ) if delete_vhd : path += '?comp=media' return self . _perform_delete ( path , as_async = True )

Removes the specified data disk from a virtual machine .


def add_disk(self, has_operating_system, label, media_link, name, os):
        '''
        Adds a disk to the user image repository. The disk can be an OS disk
        or a data disk.

        has_operating_system:
            Deprecated.
        label:
            Specifies the description of the disk.
        media_link:
            Specifies the location of the blob in Windows Azure blob store
            where the media for the disk is located. The blob location must
            belong to the storage account in the current subscription specified
            by the <subscription-id> value in the operation call. Example:
            http://example.blob.core.windows.net/disks/mydisk.vhd
        name:
            Specifies a name for the disk. Windows Azure uses the name to
            identify the disk when creating virtual machines from the disk.
        os:
            The OS type of the disk. Possible values are: Linux, Windows
        '''
        _validate_not_none('label', label)
        _validate_not_none('media_link', media_link)
        _validate_not_none('name', name)
        _validate_not_none('os', os)
        return self._perform_post(self._get_disk_path(),
                                  _XmlSerializer.disk_to_xml(
                                      label,
                                      media_link,
                                      name,
                                      os))

def add_disk ( self , has_operating_system , label , media_link , name , os ) : _validate_not_none ( 'label' , label ) _validate_not_none ( 'media_link' , media_link ) _validate_not_none ( 'name' , name ) _validate_not_none ( 'os' , os ) return self . _perform_post ( self . _get_disk_path ( ) , _XmlSerializer . disk_to_xml ( label , media_link , name , os ) )

Adds a disk to the user image repository . The disk can be an OS disk or a data disk .


def update_disk(self, disk_name, has_operating_system=None, label=None, media_link=None,
                    name=None, os=None):
        '''
        Updates an existing disk in your image repository.

        disk_name:
            The name of the disk to update.
        has_operating_system:
            Deprecated.
        label:
            Specifies the description of the disk.
        media_link:
            Deprecated.
        name:
            Deprecated.
        os:
            Deprecated.
        '''
        _validate_not_none('disk_name', disk_name)
        _validate_not_none('label', label)
        return self._perform_put(self._get_disk_path(disk_name),
                                 _XmlSerializer.disk_to_xml(
                                     label,
                                     None,
                                     None,
                                     None))

def update_disk ( self , disk_name , has_operating_system = None , label = None , media_link = None , name = None , os = None ) : _validate_not_none ( 'disk_name' , disk_name ) _validate_not_none ( 'label' , label ) return self . _perform_put ( self . _get_disk_path ( disk_name ) , _XmlSerializer . disk_to_xml ( label , None , None , None ) )

Updates an existing disk in your image repository .


def delete_disk(self, disk_name, delete_vhd=False):
        '''
        Deletes the specified data or operating system disk from your image
        repository.

        disk_name:
            The name of the disk to delete.
        delete_vhd:
            Deletes the underlying vhd blob in Azure storage.
        '''
        _validate_not_none('disk_name', disk_name)
        path = self._get_disk_path(disk_name)
        if delete_vhd:
            path += '?comp=media'
        return self._perform_delete(path)

def delete_disk ( self , disk_name , delete_vhd = False ) : _validate_not_none ( 'disk_name' , disk_name ) path = self . _get_disk_path ( disk_name ) if delete_vhd : path += '?comp=media' return self . _perform_delete ( path )

Deletes the specified data or operating system disk from your image repository .


def summarize_for_management_group(
            self, management_group_name, query_options=None, custom_headers=None, raw=False, **operation_config):
        """Summarizes policy states for the resources under the management group.

        :param management_group_name: Management group name.
        :type management_group_name: str
        :param query_options: Additional parameters for the operation
        :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions
        :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<msrest:optionsforoperations>`.
        :return: SummarizeResults or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`QueryFailureException<azure.mgmt.policyinsights.models.QueryFailureException>`
        """
        top = None
        if query_options is not None:
            top = query_options.top
        from_parameter = None
        if query_options is not None:
            from_parameter = query_options.from_property
        to = None
        if query_options is not None:
            to = query_options.to
        filter = None
        if query_options is not None:
            filter = query_options.filter

        # Construct URL
        url = self.summarize_for_management_group.metadata['url']
        path_format_arguments = {
            'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'),
            'managementGroupsNamespace': self._serialize.url("self.management_groups_namespace", self.management_groups_namespace, 'str'),
            'managementGroupName': self._serialize.url("management_group_name", management_group_name, 'str')
        }
        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')
        if top is not None:
            query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0)
        if from_parameter is not None:
            query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601')
        if to is not None:
            query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601')
        if filter is not None:
            query_parameters['$filter'] = self._serialize.query("filter", filter, '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.post(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise models.QueryFailureException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('SummarizeResults', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
summarize_for_management_group
(
self
,
management_group_name
,
query_options
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
top
=
if
query_options
is
not
:
top
=
query_options
.
top
from_parameter
=
if
query_options
is
not
:
from_parameter
=
query_options
.
from_property
to
=
if
query_options
is
not
:
to
=
query_options
.
to
filter
=
if
query_options
is
not
:
filter
=
query_options
.
filter
# Construct URL
url
=
self
.
summarize_for_management_group
.
metadata
[
'url'
]
path_format_arguments
=
{
'policyStatesSummaryResource'
:
self
.
_serialize
.
url
(
"self.policy_states_summary_resource"
,
self
.
policy_states_summary_resource
,
'str'
)
,
'managementGroupsNamespace'
:
self
.
_serialize
.
url
(
"self.management_groups_namespace"
,
self
.
management_groups_namespace
,
'str'
)
,
'managementGroupName'
:
self
.
_serialize
.
url
(
"management_group_name"
,
management_group_name
,
'str'
)
}
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'
)
if
top
is
not
:
query_parameters
[
'$top'
]
=
self
.
_serialize
.
query
(
"top"
,
top
,
'int'
,
minimum
=
0
)
if
from_parameter
is
not
:
query_parameters
[
'$from'
]
=
self
.
_serialize
.
query
(
"from_parameter"
,
from_parameter
,
'iso-8601'
)
if
to
is
not
:
query_parameters
[
'$to'
]
=
self
.
_serialize
.
query
(
"to"
,
to
,
'iso-8601'
)
if
filter
is
not
:
query_parameters
[
'$filter'
]
=
self
.
_serialize
.
query
(
"filter"
,
filter
,
'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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct and send request
request
=
self
.
_client
.
post
(
url
,
query_parameters
,
header_parameters
)
response
=
self
.
_client
.
send
(
request
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
QueryFailureException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'SummarizeResults'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Summarizes policy states for the resources under the management group .


def _build_receiver(self):
        """This is a temporary patch pending a fix in uAMQP."""
        # pylint: disable=protected-access
        self._handler.message_handler = self._handler.receiver_type(
            self._handler._session,
            self._handler._remote_address,
            self._handler._name,
            on_message_received=self._handler._message_received,
            name='receiver-link-{}'.format(uuid.uuid4()),
            debug=self._handler._debug_trace,
            prefetch=self._handler._prefetch,
            max_message_size=self._handler._max_message_size,
            properties=self._handler._link_properties,
            error_policy=self._handler._error_policy,
            encoding=self._handler._encoding)
        if self.mode != ReceiveSettleMode.PeekLock:
            self._handler.message_handler.send_settle_mode = constants.SenderSettleMode.Settled
            self._handler.message_handler.receive_settle_mode = constants.ReceiverSettleMode.ReceiveAndDelete
            self._handler.message_handler._settle_mode = constants.ReceiverSettleMode.ReceiveAndDelete
        self._handler.message_handler.open()

def
_build_receiver
(
self
)
:
# pylint: disable=protected-access
self
.
_handler
.
message_handler
=
self
.
_handler
.
receiver_type
(
self
.
_handler
.
_session
,
self
.
_handler
.
_remote_address
,
self
.
_handler
.
_name
,
on_message_received
=
self
.
_handler
.
_message_received
,
name
=
'receiver-link-{}'
.
format
(
uuid
.
uuid4
(
)
)
,
debug
=
self
.
_handler
.
_debug_trace
,
prefetch
=
self
.
_handler
.
_prefetch
,
max_message_size
=
self
.
_handler
.
_max_message_size
,
properties
=
self
.
_handler
.
_link_properties
,
error_policy
=
self
.
_handler
.
_error_policy
,
encoding
=
self
.
_handler
.
_encoding
)
if
self
.
mode
!=
ReceiveSettleMode
.
PeekLock
:
self
.
_handler
.
message_handler
.
send_settle_mode
=
constants
.
SenderSettleMode
.
Settled
self
.
_handler
.
message_handler
.
receive_settle_mode
=
constants
.
ReceiverSettleMode
.
ReceiveAndDelete
self
.
_handler
.
message_handler
.
_settle_mode
=
constants
.
ReceiverSettleMode
.
ReceiveAndDelete
self
.
_handler
.
message_handler
.
open
(
)

This is a temporary patch pending a fix in uAMQP .


def fetch_next(self, max_batch_size=None, timeout=None):
        """Receive a batch of messages at once.

        This approach it optimal if you wish to process multiple messages simultaneously. Note that the
        number of messages retrieved in a single batch will be dependent on
        whether `prefetch` was set for the receiver. This call will prioritize returning
        quickly over meeting a specified batch size, and so will return as soon as at least
        one message is received and there is a gap in incoming messages regardless
        of the specified batch size.

        :param max_batch_size: Maximum number of messages in the batch. Actual number
         returned will depend on prefetch size and incoming stream rate.
        :type max_batch_size: int
        :param timeout: The time to wait in seconds for the first message to arrive.
         If no messages arrive, and no timeout is specified, this call will not return
         until the connection is closed. If specified, an no messages arrive within the
         timeout period, an empty list will be returned.
        :rtype: list[~azure.servicebus.common.message.Message]

        Example:
            .. literalinclude:: ../examples/test_examples.py
                :start-after: [START fetch_next_messages]
                :end-before: [END fetch_next_messages]
                :language: python
                :dedent: 4
                :caption: Get the messages in batch from the receiver

        """
        self._can_run()
        wrapped_batch = []
        max_batch_size = max_batch_size or self._handler._prefetch  # pylint: disable=protected-access
        try:
            timeout_ms = 1000 * timeout if timeout else 0
            batch = self._handler.receive_message_batch(
                max_batch_size=max_batch_size,
                timeout=timeout_ms)
            for received in batch:
                message = self._build_message(received)
                wrapped_batch.append(message)
        except Exception as e:  # pylint: disable=broad-except
            self._handle_exception(e)
        return wrapped_batch

def
fetch_next
(
self
,
max_batch_size
=
,
timeout
=
)
:
self
.
_can_run
(
)
wrapped_batch
=
[
]
max_batch_size
=
max_batch_size
or
self
.
_handler
.
_prefetch
# pylint: disable=protected-access
try
:
timeout_ms
=
1000
*
timeout
if
timeout
else
0
batch
=
self
.
_handler
.
receive_message_batch
(
max_batch_size
=
max_batch_size
,
timeout
=
timeout_ms
)
for
received
in
batch
:
message
=
self
.
_build_message
(
received
)
wrapped_batch
.
append
(
message
)
except
Exception
as
e
:
# pylint: disable=broad-except
self
.
_handle_exception
(
e
)
return
wrapped_batch


def renew_lock(self):
        """Renew the session lock.

        This operation must be performed periodically in order to retain a lock on the
        session to continue message processing.
        Once the lock is lost the connection will be closed. This operation can
        also be performed as a threaded background task by registering the session
        with an `azure.servicebus.AutoLockRenew` instance.

        Example:
            .. literalinclude:: ../examples/test_examples.py
                :start-after: [START renew_lock]
                :end-before: [END renew_lock]
                :language: python
                :dedent: 4
                :caption: Renew the session lock before it expires

        """
        self._can_run()
        expiry = self._mgmt_request_response(
            REQUEST_RESPONSE_RENEW_SESSION_LOCK_OPERATION,
            {'session-id': self.session_id},
            mgmt_handlers.default)
        self.locked_until = datetime.datetime.fromtimestamp(expiry[b'expiration']/1000.0)


def create_or_update(
            self, resource_group_name, vm_scale_set_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
        """Create or update a VM scale set.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param vm_scale_set_name: The name of the VM scale set to create or
         update.
        :type vm_scale_set_name: str
        :param parameters: The scale set object.
        :type parameters:
         ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet
        :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 VirtualMachineScaleSet
         or ClientRawResponse<VirtualMachineScaleSet> if raw==True
        :rtype:
         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet]
         or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet]]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._create_or_update_initial(
            resource_group_name=resource_group_name,
            vm_scale_set_name=vm_scale_set_name,
            parameters=parameters,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            deserialized = self._deserialize('VirtualMachineScaleSet', 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)

def create_or_update ( self , resource_group_name , vm_scale_set_name , parameters , custom_headers = None , raw = False , polling = True , * * operation_config ) : raw_result = self . _create_or_update_initial ( resource_group_name = resource_group_name , vm_scale_set_name = vm_scale_set_name , parameters = parameters , custom_headers = custom_headers , raw = True , * * operation_config ) def get_long_running_output ( response ) : deserialized = self . _deserialize ( 'VirtualMachineScaleSet' , 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 )


def convert_to_single_placement_group(
            self, resource_group_name, vm_scale_set_name, active_placement_group_id=None, custom_headers=None, raw=False, **operation_config):
        """Converts SinglePlacementGroup property to false for a existing virtual
        machine scale set.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param vm_scale_set_name: The name of the virtual machine scale set to
         create or update.
        :type vm_scale_set_name: str
        :param active_placement_group_id: Id of the placement group in which
         you want future virtual machine instances to be placed. To query
         placement group Id, please use Virtual Machine Scale Set VMs - Get
         API. If not provided, the platform will choose one with maximum number
         of virtual machine instances.
        :type active_placement_group_id: 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<msrest:optionsforoperations>`.
        :return: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        parameters = models.VMScaleSetConvertToSinglePlacementGroupInput(active_placement_group_id=active_placement_group_id)

        # Construct URL
        url = self.convert_to_single_placement_group.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput')

        # 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]:
            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

Converts SinglePlacementGroup property to false for a existing virtual machine scale set .


def screen_text(
            self, text_content_type, text_content, language=None, autocorrect=False, pii=False, list_id=None, classify=False, custom_headers=None, raw=False, callback=None, **operation_config):
        """Detect profanity and match against custom and shared blacklists.

        Detects profanity in more than 100 languages and match against custom
        and shared blacklists.

        :param text_content_type: The content type. Possible values include:
         'text/plain', 'text/html', 'text/xml', 'text/markdown'
        :type text_content_type: str
        :param text_content: Content to screen.
        :type text_content: Generator
        :param language: Language of the text.
        :type language: str
        :param autocorrect: Autocorrect text.
        :type autocorrect: bool
        :param pii: Detect personal identifiable information.
        :type pii: bool
        :param list_id: The list Id.
        :type list_id: str
        :param classify: Classify input.
        :type classify: bool
        :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<msrest:optionsforoperations>`.
        :return: Screen or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.contentmoderator.models.Screen
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.screen_text.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if language is not None:
            query_parameters['language'] = self._serialize.query("language", language, 'str')
        if autocorrect is not None:
            query_parameters['autocorrect'] = self._serialize.query("autocorrect", autocorrect, 'bool')
        if pii is not None:
            query_parameters['PII'] = self._serialize.query("pii", pii, 'bool')
        if list_id is not None:
            query_parameters['listId'] = self._serialize.query("list_id", list_id, 'str')
        if classify is not None:
            query_parameters['classify'] = self._serialize.query("classify", classify, 'bool')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'text/plain'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("text_content_type", text_content_type, 'str')

        # Construct body
        body_content = self._client.stream_upload(text_content, callback)

        # 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]:
            raise models.APIErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('Screen', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
screen_text
(
self
,
text_content_type
,
text_content
,
language
=
,
autocorrect
=
False
,
pii
=
False
,
list_id
=
,
classify
=
False
,
custom_headers
=
,
raw
=
False
,
callback
=
,
*
*
operation_config
)
:
# Construct URL
url
=
self
.
screen_text
.
metadata
[
'url'
]
path_format_arguments
=
{
'Endpoint'
:
self
.
_serialize
.
url
(
"self.config.endpoint"
,
self
.
config
.
endpoint
,
'str'
,
skip_quote
=
True
)
}
url
=
self
.
_client
.
format_url
(
url
,
*
*
path_format_arguments
)
# Construct parameters
query_parameters
=
{
}
if
language
is
not
:
query_parameters
[
'language'
]
=
self
.
_serialize
.
query
(
"language"
,
language
,
'str'
)
if
autocorrect
is
not
:
query_parameters
[
'autocorrect'
]
=
self
.
_serialize
.
query
(
"autocorrect"
,
autocorrect
,
'bool'
)
if
pii
is
not
:
query_parameters
[
'PII'
]
=
self
.
_serialize
.
query
(
"pii"
,
pii
,
'bool'
)
if
list_id
is
not
:
query_parameters
[
'listId'
]
=
self
.
_serialize
.
query
(
"list_id"
,
list_id
,
'str'
)
if
classify
is
not
:
query_parameters
[
'classify'
]
=
self
.
_serialize
.
query
(
"classify"
,
classify
,
'bool'
)
# Construct headers
header_parameters
=
{
}
header_parameters
[
'Accept'
]
=
'application/json'
header_parameters
[
'Content-Type'
]
=
'text/plain'
if
custom_headers
:
header_parameters
.
update
(
custom_headers
)
header_parameters
[
'Content-Type'
]
=
self
.
_serialize
.
header
(
"text_content_type"
,
text_content_type
,
'str'
)
# Construct body
body_content
=
self
.
_client
.
stream_upload
(
text_content
,
callback
)
# 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
]
:
raise
models
.
APIErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'Screen'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Detect profanity and match against custom and shared blacklists .


def create_key(
            self, vault_base_url, key_name, kty, key_size=None, key_ops=None, key_attributes=None, tags=None, curve=None, custom_headers=None, raw=False, **operation_config):
        """Creates a new key, stores it, then returns key parameters and
        attributes to the client.

        The create key operation can be used to create any key type in Azure
        Key Vault. If the named key already exists, Azure Key Vault creates a
        new version of the key. It requires the keys/create permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param key_name: The name for the new key. The system will generate
         the version name for the new key.
        :type key_name: str
        :param kty: The type of key to create. For valid values, see
         JsonWebKeyType. Possible values include: 'EC', 'EC-HSM', 'RSA',
         'RSA-HSM', 'oct'
        :type kty: str or ~azure.keyvault.v2016_10_01.models.JsonWebKeyType
        :param key_size: The key size in bits. For example: 2048, 3072, or
         4096 for RSA.
        :type key_size: int
        :param key_ops:
        :type key_ops: list[str or
         ~azure.keyvault.v2016_10_01.models.JsonWebKeyOperation]
        :param key_attributes:
        :type key_attributes: ~azure.keyvault.v2016_10_01.models.KeyAttributes
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: dict[str, str]
        :param curve: Elliptic curve name. For valid values, see
         JsonWebKeyCurveName. Possible values include: 'P-256', 'P-384',
         'P-521', 'SECP256K1'
        :type curve: str or
         ~azure.keyvault.v2016_10_01.models.JsonWebKeyCurveName
        :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<msrest:optionsforoperations>`.
        :return: KeyBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.KeyBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.KeyCreateParameters(kty=kty, key_size=key_size, key_ops=key_ops, key_attributes=key_attributes, tags=tags, curve=curve)

        # Construct URL
        url = self.create_key.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'key-name': self._serialize.url("key_name", key_name, 'str', pattern=r'^[0-9a-zA-Z-]+$')
        }
        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['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(parameters, 'KeyCreateParameters')

        # Construct and send request
        request = self._client.post(url, query_parameters)
        response = self._client.send(
            request, header_parameters, body_content, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise models.KeyVaultErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('KeyBundle', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
create_key
(
self
,
vault_base_url
,
key_name
,
kty
,
key_size
=
,
key_ops
=
,
key_attributes
=
,
tags
=
,
curve
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
parameters
=
models
.
KeyCreateParameters
(
kty
=
kty
,
key_size
=
key_size
,
key_ops
=
key_ops
,
key_attributes
=
key_attributes
,
tags
=
tags
,
curve
=
curve
)
# Construct URL
url
=
self
.
create_key
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'key-name'
:
self
.
_serialize
.
url
(
"key_name"
,
key_name
,
'str'
,
pattern
=
r'^[0-9a-zA-Z-]+$'
)
}
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
[
'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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
parameters
,
'KeyCreateParameters'
)
# Construct and send request
request
=
self
.
_client
.
post
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'KeyBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Creates a new key stores it then returns key parameters and attributes to the client .


def import_key(
            self, vault_base_url, key_name, key, hsm=None, key_attributes=None, tags=None, custom_headers=None, raw=False, **operation_config):
        """Imports an externally created key, stores it, and returns key
        parameters and attributes to the client.

        The import key operation may be used to import any key type into an
        Azure Key Vault. If the named key already exists, Azure Key Vault
        creates a new version of the key. This operation requires the
        keys/import permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param key_name: Name for the imported key.
        :type key_name: str
        :param key: The Json web key
        :type key: ~azure.keyvault.v2016_10_01.models.JsonWebKey
        :param hsm: Whether to import as a hardware key (HSM) or software key.
        :type hsm: bool
        :param key_attributes: The key management attributes.
        :type key_attributes: ~azure.keyvault.v2016_10_01.models.KeyAttributes
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: 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<msrest:optionsforoperations>`.
        :return: KeyBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.KeyBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.KeyImportParameters(hsm=hsm, key=key, key_attributes=key_attributes, tags=tags)

        # Construct URL
        url = self.import_key.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'key-name': self._serialize.url("key_name", key_name, 'str', pattern=r'^[0-9a-zA-Z-]+$')
        }
        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['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(parameters, 'KeyImportParameters')

        # Construct and send request
        request = self._client.put(url, query_parameters)
        response = self._client.send(
            request, header_parameters, body_content, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise models.KeyVaultErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('KeyBundle', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
import_key
(
self
,
vault_base_url
,
key_name
,
key
,
hsm
=
,
key_attributes
=
,
tags
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
parameters
=
models
.
KeyImportParameters
(
hsm
=
hsm
,
key
=
key
,
key_attributes
=
key_attributes
,
tags
=
tags
)
# Construct URL
url
=
self
.
import_key
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'key-name'
:
self
.
_serialize
.
url
(
"key_name"
,
key_name
,
'str'
,
pattern
=
r'^[0-9a-zA-Z-]+$'
)
}
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
[
'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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
parameters
,
'KeyImportParameters'
)
# Construct and send request
request
=
self
.
_client
.
put
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'KeyBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Imports an externally created key stores it and returns key parameters and attributes to the client .


def update_key(
            self, vault_base_url, key_name, key_version, key_ops=None, key_attributes=None, tags=None, custom_headers=None, raw=False, **operation_config):
        """The update key operation changes specified attributes of a stored key
        and can be applied to any key type and key version stored in Azure Key
        Vault.

        In order to perform this operation, the key must already exist in the
        Key Vault. Note: The cryptographic material of a key itself cannot be
        changed. This operation requires the keys/update permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param key_name: The name of key to update.
        :type key_name: str
        :param key_version: The version of the key to update.
        :type key_version: str
        :param key_ops: Json web key operations. For more information on
         possible key operations, see JsonWebKeyOperation.
        :type key_ops: list[str or
         ~azure.keyvault.v2016_10_01.models.JsonWebKeyOperation]
        :param key_attributes:
        :type key_attributes: ~azure.keyvault.v2016_10_01.models.KeyAttributes
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: 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<msrest:optionsforoperations>`.
        :return: KeyBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.KeyBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.KeyUpdateParameters(key_ops=key_ops, key_attributes=key_attributes, tags=tags)

        # Construct URL
        url = self.update_key.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'key-name': self._serialize.url("key_name", key_name, 'str'),
            'key-version': self._serialize.url("key_version", key_version, 'str')
        }
        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['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(parameters, 'KeyUpdateParameters')

        # Construct and send request
        request = self._client.patch(url, query_parameters)
        response = self._client.send(
            request, header_parameters, body_content, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise models.KeyVaultErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('KeyBundle', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
update_key
(
self
,
vault_base_url
,
key_name
,
key_version
,
key_ops
=
,
key_attributes
=
,
tags
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
parameters
=
models
.
KeyUpdateParameters
(
key_ops
=
key_ops
,
key_attributes
=
key_attributes
,
tags
=
tags
)
# Construct URL
url
=
self
.
update_key
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'key-name'
:
self
.
_serialize
.
url
(
"key_name"
,
key_name
,
'str'
)
,
'key-version'
:
self
.
_serialize
.
url
(
"key_version"
,
key_version
,
'str'
)
}
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
[
'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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
parameters
,
'KeyUpdateParameters'
)
# Construct and send request
request
=
self
.
_client
.
patch
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'KeyBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault .


def set_secret(
            self, vault_base_url, secret_name, value, tags=None, content_type=None, secret_attributes=None, custom_headers=None, raw=False, **operation_config):
        """Sets a secret in a specified key vault.

        The SET operation adds a secret to the Azure Key Vault. If the named
        secret already exists, Azure Key Vault creates a new version of that
        secret. This operation requires the secrets/set permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param secret_name: The name of the secret.
        :type secret_name: str
        :param value: The value of the secret.
        :type value: str
        :param tags: Application specific metadata in the form of key-value
         pairs.
        :type tags: dict[str, str]
        :param content_type: Type of the secret value such as a password.
        :type content_type: str
        :param secret_attributes: The secret management attributes.
        :type secret_attributes:
         ~azure.keyvault.v2016_10_01.models.SecretAttributes
        :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<msrest:optionsforoperations>`.
        :return: SecretBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.SecretBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameters = models.SecretSetParameters(value=value, tags=tags, content_type=content_type, secret_attributes=secret_attributes)

        # Construct URL
        url = self.set_secret.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'secret-name': self._serialize.url("secret_name", secret_name, 'str', pattern=r'^[0-9a-zA-Z-]+$')
        }
        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['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(parameters, 'SecretSetParameters')

        # Construct and send request
        request = self._client.put(url, query_parameters)
        response = self._client.send(
            request, header_parameters, body_content, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise models.KeyVaultErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('SecretBundle', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
set_secret
(
self
,
vault_base_url
,
secret_name
,
value
,
tags
=
,
content_type
=
,
secret_attributes
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
parameters
=
models
.
SecretSetParameters
(
value
=
value
,
tags
=
tags
,
content_type
=
content_type
,
secret_attributes
=
secret_attributes
)
# Construct URL
url
=
self
.
set_secret
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'secret-name'
:
self
.
_serialize
.
url
(
"secret_name"
,
secret_name
,
'str'
,
pattern
=
r'^[0-9a-zA-Z-]+$'
)
}
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
[
'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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
parameters
,
'SecretSetParameters'
)
# Construct and send request
request
=
self
.
_client
.
put
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'SecretBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized

Sets a secret in a specified key vault .


def set_certificate_issuer(
            self, vault_base_url, issuer_name, provider, credentials=None, organization_details=None, attributes=None, custom_headers=None, raw=False, **operation_config):
        """Sets the specified certificate issuer.

        The SetCertificateIssuer operation adds or updates the specified
        certificate issuer. This operation requires the certificates/setissuers
        permission.

        :param vault_base_url: The vault name, for example
         https://myvault.vault.azure.net.
        :type vault_base_url: str
        :param issuer_name: The name of the issuer.
        :type issuer_name: str
        :param provider: The issuer provider.
        :type provider: str
        :param credentials: The credentials to be used for the issuer.
        :type credentials:
         ~azure.keyvault.v2016_10_01.models.IssuerCredentials
        :param organization_details: Details of the organization as provided
         to the issuer.
        :type organization_details:
         ~azure.keyvault.v2016_10_01.models.OrganizationDetails
        :param attributes: Attributes of the issuer object.
        :type attributes: ~azure.keyvault.v2016_10_01.models.IssuerAttributes
        :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<msrest:optionsforoperations>`.
        :return: IssuerBundle or ClientRawResponse if raw=true
        :rtype: ~azure.keyvault.v2016_10_01.models.IssuerBundle or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`KeyVaultErrorException<azure.keyvault.v2016_10_01.models.KeyVaultErrorException>`
        """
        parameter = models.CertificateIssuerSetParameters(provider=provider, credentials=credentials, organization_details=organization_details, attributes=attributes)

        # Construct URL
        url = self.set_certificate_issuer.metadata['url']
        path_format_arguments = {
            'vaultBaseUrl': self._serialize.url("vault_base_url", vault_base_url, 'str', skip_quote=True),
            'issuer-name': self._serialize.url("issuer_name", issuer_name, 'str')
        }
        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['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(parameter, 'CertificateIssuerSetParameters')

        # Construct and send request
        request = self._client.put(url, query_parameters)
        response = self._client.send(
            request, header_parameters, body_content, stream=False, **operation_config)

        if response.status_code not in [200]:
            raise models.KeyVaultErrorException(self._deserialize, response)

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('IssuerBundle', response)

        if raw:
            client_raw_response = ClientRawResponse(deserialized, response)
            return client_raw_response

        return deserialized

def
set_certificate_issuer
(
self
,
vault_base_url
,
issuer_name
,
provider
,
credentials
=
,
organization_details
=
,
attributes
=
,
custom_headers
=
,
raw
=
False
,
*
*
operation_config
)
:
parameter
=
models
.
CertificateIssuerSetParameters
(
provider
=
provider
,
credentials
=
credentials
,
organization_details
=
organization_details
,
attributes
=
attributes
)
# Construct URL
url
=
self
.
set_certificate_issuer
.
metadata
[
'url'
]
path_format_arguments
=
{
'vaultBaseUrl'
:
self
.
_serialize
.
url
(
"vault_base_url"
,
vault_base_url
,
'str'
,
skip_quote
=
True
)
,
'issuer-name'
:
self
.
_serialize
.
url
(
"issuer_name"
,
issuer_name
,
'str'
)
}
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
[
'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
:
header_parameters
[
'accept-language'
]
=
self
.
_serialize
.
header
(
"self.config.accept_language"
,
self
.
config
.
accept_language
,
'str'
)
# Construct body
body_content
=
self
.
_serialize
.
body
(
parameter
,
'CertificateIssuerSetParameters'
)
# Construct and send request
request
=
self
.
_client
.
put
(
url
,
query_parameters
)
response
=
self
.
_client
.
send
(
request
,
header_parameters
,
body_content
,
stream
=
False
,
*
*
operation_config
)
if
response
.
status_code
not
in
[
200
]
:
raise
models
.
KeyVaultErrorException
(
self
.
_deserialize
,
response
)
deserialized
=
if
response
.
status_code
==
200
:
deserialized
=
self
.
_deserialize
(
'IssuerBundle'
,
response
)
if
raw
:
client_raw_response
=
ClientRawResponse
(
deserialized
,
response
)
return
client_raw_response
return
deserialized


def from_connection_string(cls, conn_str, *, loop=None, **kwargs):
        """Create a Service Bus client from a connection string.

        :param conn_str: The connection string.
        :type conn_str: str

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START create_async_servicebus_client_connstr]
                :end-before: [END create_async_servicebus_client_connstr]
                :language: python
                :dedent: 4
                :caption: Create a ServiceBusClient via a connection string.

        """
        address, policy, key, _ = parse_conn_str(conn_str)
        parsed_namespace = urlparse(address)
        namespace, _, base = parsed_namespace.hostname.partition('.')
        return cls(
            service_namespace=namespace,
            shared_access_key_name=policy,
            shared_access_key_value=key,
            host_base='.' + base,
            loop=loop,
            **kwargs)

def from_connection_string ( cls , conn_str , * , loop = None , * * kwargs ) : address , policy , key , _ = parse_conn_str ( conn_str ) parsed_namespace = urlparse ( address ) namespace , _ , base = parsed_namespace . hostname . partition ( '.' ) return cls ( service_namespace = namespace , shared_access_key_name = policy , shared_access_key_value = key , host_base = '.' + base , loop = loop , * * kwargs )

Create a Service Bus client from a connection string .


def get_subscription(self, topic_name, subscription_name):
        """Get an async client for a subscription entity.

        :param topic_name: The name of the topic.
        :type topic_name: str
        :param subscription_name: The name of the subscription.
        :type subscription_name: str
        :rtype: ~azure.servicebus.aio.async_client.SubscriptionClient
        :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found.
        :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the subscription is not found.

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START get_async_subscription_client]
                :end-before: [END get_async_subscription_client]
                :language: python
                :dedent: 4
                :caption: Get a TopicClient for the specified topic.

        """
        try:
            subscription = self.mgmt_client.get_subscription(topic_name, subscription_name)
        except requests.exceptions.ConnectionError as e:
            raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
        except AzureServiceBusResourceNotFound:
            raise ServiceBusResourceNotFound("Specificed subscription does not exist.")
        return SubscriptionClient.from_entity(
            self._get_host(), topic_name, subscription,
            shared_access_key_name=self.shared_access_key_name,
            shared_access_key_value=self.shared_access_key_value,
            loop=self.loop,
            debug=self.debug)

Get an async client for a subscription entity .


def list_subscriptions(self, topic_name):
        """Get an async client for all subscription entities in the topic.

        :param topic_name: The topic to list subscriptions for.
        :type topic_name: str
        :rtype: list[~azure.servicebus.aio.async_client.SubscriptionClient]
        :raises: ~azure.servicebus.common.errors.ServiceBusConnectionError if the namespace is not found.
        :raises: ~azure.servicebus.common.errors.ServiceBusResourceNotFound if the topic is not found.
        """
        try:
            subs = self.mgmt_client.list_subscriptions(topic_name)
        except requests.exceptions.ConnectionError as e:
            raise ServiceBusConnectionError("Namespace: {} not found".format(self.service_namespace), e)
        except AzureServiceBusResourceNotFound:
            raise ServiceBusResourceNotFound("Specificed topic does not exist.")
        sub_clients = []
        for sub in subs:
            sub_clients.append(SubscriptionClient.from_entity(
                self._get_host(), topic_name, sub,
                shared_access_key_name=self.shared_access_key_name,
                shared_access_key_value=self.shared_access_key_value,
                loop=self.loop,
                debug=self.debug))
        return sub_clients

def
list_subscriptions
(
self
,
topic_name
)
:
try
:
subs
=
self
.
mgmt_client
.
list_subscriptions
(
topic_name
)
except
requests
.
exceptions
.
ConnectionError
as
e
:
raise
ServiceBusConnectionError
(
"Namespace: {} not found"
.
format
(
self
.
service_namespace
)
,
e
)
except
AzureServiceBusResourceNotFound
:
raise
ServiceBusResourceNotFound
(
"Specificed topic does not exist."
)
sub_clients
=
[
]
for
sub
in
subs
:
sub_clients
.
append
(
SubscriptionClient
.
from_entity
(
self
.
_get_host
(
)
,
topic_name
,
sub
,
shared_access_key_name
=
self
.
shared_access_key_name
,
shared_access_key_value
=
self
.
shared_access_key_value
,
loop
=
self
.
loop
,
debug
=
self
.
debug
)
)
return
sub_clients

Get an async client for all subscription entities in the topic .


async def send(self, messages, message_timeout=0, session=None, **kwargs):
        """Send one or more messages to the current entity.

        This operation will open a single-use connection, send the supplied messages, and close
        connection. If the entity requires sessions, a session ID must be either
        provided here, or set on each outgoing message.

        :param messages: One or more messages to be sent.
        :type messages: ~azure.servicebus.aio.async_message.Message or
         list[~azure.servicebus.aio.async_message.Message]
        :param message_timeout: The period in seconds during which the Message must be
         sent. If the send is not completed in this time it will return a failure result.
        :type message_timeout: int
        :param session: An optional session ID. If supplied this session ID will be
         applied to every outgoing message sent with this Sender.
         If an individual message already has a session ID, that will be
         used instead. If no session ID is supplied here, nor set on an outgoing
         message, a ValueError will be raised if the entity is sessionful.
        :type session: str or ~uuid.Guid
        :raises: ~azure.servicebus.common.errors.MessageSendFailed
        :returns: A list of the send results of all the messages. Each
         send result is a tuple with two values. The first is a boolean, indicating `True`
         if the message sent, or `False` if it failed. The second is an error if the message
         failed, otherwise it will be `None`.
        :rtype: list[tuple[bool, ~azure.servicebus.common.errors.MessageSendFailed]]

        Example:
            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START queue_client_send]
                :end-before: [END queue_client_send]
                :language: python
                :dedent: 4
                :caption: Send a single message.

            .. literalinclude:: ../examples/async_examples/test_examples_async.py
                :start-after: [START queue_client_send_multiple]
                :end-before: [END queue_client_send_multiple]
                :language: python
                :dedent: 4
                :caption: Send multiple messages.

        """
        async with self.get_sender(message_timeout=message_timeout, session=session, **kwargs) as sender:
            if isinstance(messages, Message):
                sender.queue_message(messages)
            else:
                try:
                    messages = list(messages)
                except TypeError:
                    raise TypeError(
                        "Value of messages must be a 'Message' object or a synchronous iterable of 'Message' objects.")

                for m in messages:
                    if not isinstance(m, Message):
                        raise TypeError("Item in iterator is not of type 'Message'.")
                    sender.queue_message(m)

            return await sender.send_pending_messages()

Send one or more messages to the current entity .