# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

import uuid
from msrest.pipeline import ClientRawResponse

from .. import models

class DpsCertificateOperations(object):
    """DpsCertificateOperations operations.

    :param client: Client for service requests.
    :param config: Configuration of service client.
    :param serializer: An object model serializer.
    :param deserializer: An object model deserializer.
    :ivar api_version: The version of the API. Constant value: "2018-01-22".
    """

    models = models

    def __init__(self, client, config, serializer, deserializer):

        self._client = client
        self._serialize = serializer
        self._deserialize = deserializer
        self.api_version = "2018-01-22"

        self.config = config

    def get(
            self, certificate_name, resource_group_name, provisioning_service_name, if_match=None, custom_headers=None, raw=False, **operation_config):
        """Get the certificate from the provisioning service.

        :param certificate_name: Name of the certificate to retrieve.
        :type certificate_name: str
        :param resource_group_name: Resource group identifier.
        :type resource_group_name: str
        :param provisioning_service_name: Name of the provisioning service the
         certificate is associated with.
        :type provisioning_service_name: str
        :param if_match: ETag of the certificate.
        :type if_match: 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: CertificateResponse or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorDetailsException<azure.mgmt.iothubprovisioningservices.models.ErrorDetailsException>`
        """
        # Construct URL
        url = self.get.metadata['url']
        path_format_arguments = {
            'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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 if_match is not None:
            header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

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

        deserialized = None

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

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

        return deserialized
    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'}

    def create_or_update(
            self, resource_group_name, provisioning_service_name, certificate_name, if_match=None, certificate=None, custom_headers=None, raw=False, **operation_config):
        """Upload the certificate to the provisioning service.

        Add new certificate or update an existing certificate.

        :param resource_group_name: Resource group identifier.
        :type resource_group_name: str
        :param provisioning_service_name: The name of the provisioning
         service.
        :type provisioning_service_name: str
        :param certificate_name: The name of the certificate create or update.
        :type certificate_name: str
        :param if_match: ETag of the certificate. This is required to update
         an existing certificate, and ignored while creating a brand new
         certificate.
        :type if_match: str
        :param certificate: Base-64 representation of the X509 leaf
         certificate .cer file or just .pem file content.
        :type certificate: 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: CertificateResponse or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorDetailsException<azure.mgmt.iothubprovisioningservices.models.ErrorDetailsException>`
        """
        certificate_description = models.CertificateBodyDescription(certificate=certificate)

        # Construct URL
        url = self.create_or_update.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'),
            'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', max_length=256)
        }
        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 if_match is not None:
            header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
        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(certificate_description, 'CertificateBodyDescription')

        # 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.ErrorDetailsException(self._deserialize, response)

        deserialized = None

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

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

        return deserialized
    create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'}

    def delete(
            self, resource_group_name, if_match, provisioning_service_name, certificate_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, custom_headers=None, raw=False, **operation_config):
        """Delete the Provisioning Service Certificate.

        Deletes the specified certificate assosciated with the Provisioning
        Service.

        :param resource_group_name: Resource group identifier.
        :type resource_group_name: str
        :param if_match: ETag of the certificate
        :type if_match: str
        :param provisioning_service_name: The name of the provisioning
         service.
        :type provisioning_service_name: str
        :param certificate_name: This is a mandatory field, and is the logical
         name of the certificate that the provisioning service will access by.
        :type certificate_name: str
        :param certificatename: This is optional, and it is the Common Name of
         the certificate.
        :type certificatename: str
        :param certificateraw_bytes: Raw data within the certificate.
        :type certificateraw_bytes: bytearray
        :param certificateis_verified: Indicates if certificate has been
         verified by owner of the private key.
        :type certificateis_verified: bool
        :param certificatepurpose: A description that mentions the purpose of
         the certificate. Possible values include: 'clientAuthentication',
         'serverAuthentication'
        :type certificatepurpose: str or
         ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose
        :param certificatecreated: Time the certificate is created.
        :type certificatecreated: datetime
        :param certificatelast_updated: Time the certificate is last updated.
        :type certificatelast_updated: datetime
        :param certificatehas_private_key: Indicates if the certificate
         contains a private key.
        :type certificatehas_private_key: bool
        :param certificatenonce: Random number generated to indicate Proof of
         Possession.
        :type certificatenonce: 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:`ErrorDetailsException<azure.mgmt.iothubprovisioningservices.models.ErrorDetailsException>`
        """
        # Construct URL
        url = self.delete.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'),
            'certificateName': self._serialize.url("certificate_name", certificate_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if certificatename is not None:
            query_parameters['certificate.name'] = self._serialize.query("certificatename", certificatename, 'str')
        if certificateraw_bytes is not None:
            query_parameters['certificate.rawBytes'] = self._serialize.query("certificateraw_bytes", certificateraw_bytes, 'bytearray')
        if certificateis_verified is not None:
            query_parameters['certificate.isVerified'] = self._serialize.query("certificateis_verified", certificateis_verified, 'bool')
        if certificatepurpose is not None:
            query_parameters['certificate.purpose'] = self._serialize.query("certificatepurpose", certificatepurpose, 'str')
        if certificatecreated is not None:
            query_parameters['certificate.created'] = self._serialize.query("certificatecreated", certificatecreated, 'iso-8601')
        if certificatelast_updated is not None:
            query_parameters['certificate.lastUpdated'] = self._serialize.query("certificatelast_updated", certificatelast_updated, 'iso-8601')
        if certificatehas_private_key is not None:
            query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificatehas_private_key", certificatehas_private_key, 'bool')
        if certificatenonce is not None:
            query_parameters['certificate.nonce'] = self._serialize.query("certificatenonce", certificatenonce, 'str')
        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)
        header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'}

    def list(
            self, resource_group_name, provisioning_service_name, custom_headers=None, raw=False, **operation_config):
        """Get all the certificates tied to the provisioning service.

        :param resource_group_name: Name of resource group.
        :type resource_group_name: str
        :param provisioning_service_name: Name of provisioning service to
         retrieve certificates for.
        :type provisioning_service_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: CertificateListDescription or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.iothubprovisioningservices.models.CertificateListDescription
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorDetailsException<azure.mgmt.iothubprovisioningservices.models.ErrorDetailsException>`
        """
        # Construct URL
        url = self.list.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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 and send request
        request = self._client.get(url, query_parameters)
        response = self._client.send(request, header_parameters, stream=False, **operation_config)

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

        deserialized = None

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

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

        return deserialized
    list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates'}

    def generate_verification_code(
            self, certificate_name, if_match, resource_group_name, provisioning_service_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, custom_headers=None, raw=False, **operation_config):
        """Generate verification code for Proof of Possession.

        :param certificate_name: The mandatory logical name of the
         certificate, that the provisioning service uses to access.
        :type certificate_name: str
        :param if_match: ETag of the certificate. This is required to update
         an existing certificate, and ignored while creating a brand new
         certificate.
        :type if_match: str
        :param resource_group_name: name of resource group.
        :type resource_group_name: str
        :param provisioning_service_name: Name of provisioning service.
        :type provisioning_service_name: str
        :param certificatename: Common Name for the certificate.
        :type certificatename: str
        :param certificateraw_bytes: Raw data of certificate.
        :type certificateraw_bytes: bytearray
        :param certificateis_verified: Indicates if the certificate has been
         verified by owner of the private key.
        :type certificateis_verified: bool
        :param certificatepurpose: Description mentioning the purpose of the
         certificate. Possible values include: 'clientAuthentication',
         'serverAuthentication'
        :type certificatepurpose: str or
         ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose
        :param certificatecreated: Certificate creation time.
        :type certificatecreated: datetime
        :param certificatelast_updated: Certificate last updated time.
        :type certificatelast_updated: datetime
        :param certificatehas_private_key: Indicates if the certificate
         contains private key.
        :type certificatehas_private_key: bool
        :param certificatenonce: Random number generated to indicate Proof of
         Possession.
        :type certificatenonce: 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: VerificationCodeResponse or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponse
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorDetailsException<azure.mgmt.iothubprovisioningservices.models.ErrorDetailsException>`
        """
        # Construct URL
        url = self.generate_verification_code.metadata['url']
        path_format_arguments = {
            'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if certificatename is not None:
            query_parameters['certificate.name'] = self._serialize.query("certificatename", certificatename, 'str')
        if certificateraw_bytes is not None:
            query_parameters['certificate.rawBytes'] = self._serialize.query("certificateraw_bytes", certificateraw_bytes, 'bytearray')
        if certificateis_verified is not None:
            query_parameters['certificate.isVerified'] = self._serialize.query("certificateis_verified", certificateis_verified, 'bool')
        if certificatepurpose is not None:
            query_parameters['certificate.purpose'] = self._serialize.query("certificatepurpose", certificatepurpose, 'str')
        if certificatecreated is not None:
            query_parameters['certificate.created'] = self._serialize.query("certificatecreated", certificatecreated, 'iso-8601')
        if certificatelast_updated is not None:
            query_parameters['certificate.lastUpdated'] = self._serialize.query("certificatelast_updated", certificatelast_updated, 'iso-8601')
        if certificatehas_private_key is not None:
            query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificatehas_private_key", certificatehas_private_key, 'bool')
        if certificatenonce is not None:
            query_parameters['certificate.nonce'] = self._serialize.query("certificatenonce", certificatenonce, 'str')
        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)
        header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
        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)
        response = self._client.send(request, header_parameters, stream=False, **operation_config)

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

        deserialized = None

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

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

        return deserialized
    generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode'}

    def verify_certificate(
            self, certificate_name, if_match, resource_group_name, provisioning_service_name, certificatename=None, certificateraw_bytes=None, certificateis_verified=None, certificatepurpose=None, certificatecreated=None, certificatelast_updated=None, certificatehas_private_key=None, certificatenonce=None, certificate=None, custom_headers=None, raw=False, **operation_config):
        """Verify certificate's private key possession.

        Verifies the certificate's private key possession by providing the leaf
        cert issued by the verifying pre uploaded certificate.

        :param certificate_name: The mandatory logical name of the
         certificate, that the provisioning service uses to access.
        :type certificate_name: str
        :param if_match: ETag of the certificate.
        :type if_match: str
        :param resource_group_name: Resource group name.
        :type resource_group_name: str
        :param provisioning_service_name: Provisioning service name.
        :type provisioning_service_name: str
        :param certificatename: Common Name for the certificate.
        :type certificatename: str
        :param certificateraw_bytes: Raw data of certificate.
        :type certificateraw_bytes: bytearray
        :param certificateis_verified: Indicates if the certificate has been
         verified by owner of the private key.
        :type certificateis_verified: bool
        :param certificatepurpose: Describe the purpose of the certificate.
         Possible values include: 'clientAuthentication',
         'serverAuthentication'
        :type certificatepurpose: str or
         ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose
        :param certificatecreated: Certificate creation time.
        :type certificatecreated: datetime
        :param certificatelast_updated: Certificate last updated time.
        :type certificatelast_updated: datetime
        :param certificatehas_private_key: Indicates if the certificate
         contains private key.
        :type certificatehas_private_key: bool
        :param certificatenonce: Random number generated to indicate Proof of
         Possession.
        :type certificatenonce: str
        :param certificate: base-64 representation of X509 certificate .cer
         file or just .pem file content.
        :type certificate: 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: CertificateResponse or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorDetailsException<azure.mgmt.iothubprovisioningservices.models.ErrorDetailsException>`
        """
        request = models.VerificationCodeRequest(certificate=certificate)

        # Construct URL
        url = self.verify_certificate.metadata['url']
        path_format_arguments = {
            'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if certificatename is not None:
            query_parameters['certificate.name'] = self._serialize.query("certificatename", certificatename, 'str')
        if certificateraw_bytes is not None:
            query_parameters['certificate.rawBytes'] = self._serialize.query("certificateraw_bytes", certificateraw_bytes, 'bytearray')
        if certificateis_verified is not None:
            query_parameters['certificate.isVerified'] = self._serialize.query("certificateis_verified", certificateis_verified, 'bool')
        if certificatepurpose is not None:
            query_parameters['certificate.purpose'] = self._serialize.query("certificatepurpose", certificatepurpose, 'str')
        if certificatecreated is not None:
            query_parameters['certificate.created'] = self._serialize.query("certificatecreated", certificatecreated, 'iso-8601')
        if certificatelast_updated is not None:
            query_parameters['certificate.lastUpdated'] = self._serialize.query("certificatelast_updated", certificatelast_updated, 'iso-8601')
        if certificatehas_private_key is not None:
            query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificatehas_private_key", certificatehas_private_key, 'bool')
        if certificatenonce is not None:
            query_parameters['certificate.nonce'] = self._serialize.query("certificatenonce", certificatenonce, 'str')
        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)
        header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
        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(request, 'VerificationCodeRequest')

        # 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.ErrorDetailsException(self._deserialize, response)

        deserialized = None

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

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

        return deserialized
    verify_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify'}


# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

import uuid
from msrest.pipeline import ClientRawResponse

from .. import models

class EntitiesOperations(object):
    """EntitiesOperations operations.

    :param client: Client for service requests.
    :param config: Configuration of service client.
    :param serializer: An object model serializer.
    :param deserializer: An object model deserializer.
    :ivar api_version: Version of the API to be used with the client request. The current version is 2018-01-01-preview. Constant value: "2018-03-01-preview".
    """

    models = models

    def __init__(self, client, config, serializer, deserializer):

        self._client = client
        self._serialize = serializer
        self._deserialize = deserializer
        self.api_version = "2018-03-01-preview"

        self.config = config

    def list(
            self, skiptoken=None, skip=None, top=None, select=None, search=None, filter=None, view=None, group_name=None, cache_control="no-cache", custom_headers=None, raw=False, **operation_config):
        """List all entities (Management Groups, Subscriptions, etc.) for the
        authenticated user.

        :param skiptoken: Page continuation token is only used if a previous
         operation returned a partial result. If a previous response contains a
         nextLink element, the value of the nextLink element will include a
         token parameter that specifies a starting point to use for subsequent
         calls.
        :type skiptoken: str
        :param skip: Number of entities to skip over when retrieving results.
         Passing this in will override $skipToken.
        :type skip: int
        :param top: Number of elements to return when retrieving results.
         Passing this in will override $skipToken.
        :type top: int
        :param select: This parameter specifies the fields to include in the
         response. Can include any combination of
         Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g.
         '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'.
         When specified the $select parameter can override select in
         $skipToken.
        :type select: str
        :param search: The $search parameter is used in conjunction with the
         $filter parameter to return three different outputs depending on the
         parameter passed in. With $search=AllowedParents the API will return
         the entity info of all groups that the requested entity will be able
         to reparent to as determined by the user's permissions. With
         $search=AllowedChildren the API will return the entity info of all
         entities that can be added as children of the requested entity. With
         $search=ParentAndFirstLevelChildren the API will return the parent and
         first level of children that the user has either direct access to or
         indirect access via one of their descendants. Possible values include:
         'AllowedParents', 'AllowedChildren', 'ParentAndFirstLevelChildren',
         'ParentOnly', 'ChildrenOnly'
        :type search: str
        :param filter: The filter parameter allows you to filter on the name
         or display name fields. You can check for equality on the name field
         (e.g. name eq '{entityName}')  and you can check for substrings on
         either the name or display name fields(e.g. contains(name,
         '{substringToSearch}'), contains(displayName, '{substringToSearch')).
         Note that the '{entityName}' and '{substringToSearch}' fields are
         checked case insensitively.
        :type filter: str
        :param view: The view parameter allows clients to filter the type of
         data that is returned by the getEntities call. Possible values
         include: 'FullHierarchy', 'GroupsOnly', 'SubscriptionsOnly', 'Audit'
        :type view: str
        :param group_name: A filter which allows the get entities call to
         focus on a particular group (i.e. "$filter=name eq 'groupName'")
        :type group_name: str
        :param cache_control: Indicates that the request shouldn't utilize any
         caches.
        :type cache_control: 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: An iterator like instance of EntityInfo
        :rtype:
         ~azure.mgmt.managementgroups.models.EntityInfoPaged[~azure.mgmt.managementgroups.models.EntityInfo]
        :raises:
         :class:`ErrorResponseException<azure.mgmt.managementgroups.models.ErrorResponseException>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = self.list.metadata['url']

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
                if skiptoken is not None:
                    query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str')
                if skip is not None:
                    query_parameters['$skip'] = self._serialize.query("skip", skip, 'int')
                if top is not None:
                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
                if select is not None:
                    query_parameters['$select'] = self._serialize.query("select", select, 'str')
                if search is not None:
                    query_parameters['$search'] = self._serialize.query("search", search, 'str')
                if filter is not None:
                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                if view is not None:
                    query_parameters['$view'] = self._serialize.query("view", view, 'str')
                if group_name is not None:
                    query_parameters['groupName'] = self._serialize.query("group_name", group_name, 'str')

            else:
                url = next_link
                query_parameters = {}

            # Construct headers
            header_parameters = {}
            header_parameters['Accept'] = 'application/json'
            if self.config.generate_client_request_id:
                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
            if custom_headers:
                header_parameters.update(custom_headers)
            if cache_control is not None:
                header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str')
            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.ErrorResponseException(self._deserialize, response)

            return response

        # Deserialize response
        deserialized = models.EntityInfoPaged(internal_paging, self._deserialize.dependencies)

        if raw:
            header_dict = {}
            client_raw_response = models.EntityInfoPaged(internal_paging, self._deserialize.dependencies, header_dict)
            return client_raw_response

        return deserialized
    list.metadata = {'url': '/providers/Microsoft.Management/getEntities'}


# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.pipeline import ClientRawResponse

from .. import models

class ReviewsOperations(object):
    """ReviewsOperations operations.

    :param client: Client for service requests.
    :param config: Configuration of service client.
    :param serializer: An object model serializer.
    :param deserializer: An object model deserializer.
    :ivar content_type: The content type. Constant value: "text/plain".
    """

    models = models

    def __init__(self, client, config, serializer, deserializer):

        self._client = client
        self._serialize = serializer
        self._deserialize = deserializer

        self.config = config
        self.content_type = "text/plain"

    def get_review(
            self, team_name, review_id, custom_headers=None, raw=False, **operation_config):
        """Returns review details for the review Id passed.

        :param team_name: Your Team Name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_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: Review or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.contentmoderator.models.Review
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.get_review.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized
    get_review.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}'}

    def get_job_details(
            self, team_name, job_id, custom_headers=None, raw=False, **operation_config):
        """Get the Job Details for a Job Id.

        :param team_name: Your Team Name.
        :type team_name: str
        :param job_id: Id of the job.
        :type job_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: Job or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.contentmoderator.models.Job or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.get_job_details.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'JobId': self._serialize.url("job_id", job_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized
    get_job_details.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/jobs/{JobId}'}

    def create_reviews(
            self, url_content_type, team_name, create_review_body, sub_team=None, custom_headers=None, raw=False, **operation_config):
        """The reviews created would show up for Reviewers on your team. As
        Reviewers complete reviewing, results of the Review would be POSTED
        (i.e. HTTP POST) on the specified CallBackEndpoint.

CallBack Schemas

Review Completion CallBack Sample

        {

        "ReviewId": "<Review Id>",

        "ModifiedOn": "2016-10-11T22:36:32.9934851Z",

        "ModifiedBy": "<Name of the Reviewer>",

        "CallBackType": "Review",

        "ContentId": "<The ContentId that was specified input>",

        "Metadata": {

        "adultscore": "0.xxx",

        "a": "False",

        "racyscore": "0.xxx",

        "r": "True"

        },

        "ReviewerResultTags": {

        "a": "False",

        "r": "True"

        }

        }

.

        :param url_content_type: The content type.
        :type url_content_type: str
        :param team_name: Your team name.
        :type team_name: str
        :param create_review_body: Body for create reviews API
        :type create_review_body:
         list[~azure.cognitiveservices.vision.contentmoderator.models.CreateReviewBodyItem]
        :param sub_team: SubTeam of your team, you want to assign the created
         review to.
        :type sub_team: 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: list or ClientRawResponse if raw=true
        :rtype: list[str] or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.create_reviews.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if sub_team is not None:
            query_parameters['subTeam'] = self._serialize.query("sub_team", sub_team, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['UrlContentType'] = self._serialize.header("url_content_type", url_content_type, 'str')

        # Construct body
        body_content = self._serialize.body(create_review_body, '[CreateReviewBodyItem]')

        # 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('[str]', response)

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

        return deserialized
    create_reviews.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews'}

    def create_job(
            self, team_name, content_type, content_id, workflow_name, job_content_type, content_value, call_back_endpoint=None, custom_headers=None, raw=False, **operation_config):
        """A job Id will be returned for the content posted on this endpoint.
        Once the content is evaluated against the Workflow provided the review
        will be created or ignored based on the workflow expression.

CallBack Schemas

Job Completion CallBack Sample

        {

        "JobId": "<Job Id>,

        "ReviewId": "<Review Id, if the Job resulted in a Review to be
        created>",

        "WorkFlowId": "default",

        "Status": "<This will be one of Complete, InProgress, Error>",

        "ContentType": "Image",

        "ContentId": "<This is the ContentId that was specified on
        input>",

        "CallBackType": "Job",

        "Metadata": {

        "adultscore": "0.xxx",

        "a": "False",

        "racyscore": "0.xxx",

        "r": "True"

        }

        }

Review Completion CallBack Sample

        {
        "ReviewId": "<Review Id>",

        "ModifiedOn": "2016-10-11T22:36:32.9934851Z",

        "ModifiedBy": "<Name of the Reviewer>",

        "CallBackType": "Review",

        "ContentId": "<The ContentId that was specified input>",

        "Metadata": {

        "adultscore": "0.xxx",
        "a": "False",

        "racyscore": "0.xxx",

        "r": "True"

        },

        "ReviewerResultTags": {

        "a": "False",

        "r": "True"

        }

        }

.

        :param team_name: Your team name.
        :type team_name: str
        :param content_type: Image, Text or Video. Possible values include:
         'Image', 'Text', 'Video'
        :type content_type: str
        :param content_id: Id/Name to identify the content submitted.
        :type content_id: str
        :param workflow_name: Workflow Name that you want to invoke.
        :type workflow_name: str
        :param job_content_type: The content type. Possible values include:
         'application/json', 'image/jpeg'
        :type job_content_type: str
        :param content_value: Content to evaluate for a job.
        :type content_value: str
        :param call_back_endpoint: Callback endpoint for posting the create
         job result.
        :type call_back_endpoint: 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: JobId or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.contentmoderator.models.JobId
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        content = models.Content(content_value=content_value)

        # Construct URL
        url = self.create_job.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['ContentType'] = self._serialize.query("content_type", content_type, 'str')
        query_parameters['ContentId'] = self._serialize.query("content_id", content_id, 'str')
        query_parameters['WorkflowName'] = self._serialize.query("workflow_name", workflow_name, 'str')
        if call_back_endpoint is not None:
            query_parameters['CallBackEndpoint'] = self._serialize.query("call_back_endpoint", call_back_endpoint, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("job_content_type", job_content_type, 'str')

        # Construct body
        body_content = self._serialize.body(content, 'Content')

        # 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('JobId', response)

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

        return deserialized
    create_job.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/jobs'}

    def add_video_frame(
            self, team_name, review_id, timescale=None, custom_headers=None, raw=False, **operation_config):
        """The reviews created would show up for Reviewers on your team. As
        Reviewers complete reviewing, results of the Review would be POSTED
        (i.e. HTTP POST) on the specified CallBackEndpoint.

CallBack Schemas

Review Completion CallBack Sample

        {

        "ReviewId": "<Review Id>",

        "ModifiedOn": "2016-10-11T22:36:32.9934851Z",

        "ModifiedBy": "<Name of the Reviewer>",

        "CallBackType": "Review",

        "ContentId": "<The ContentId that was specified input>",

        "Metadata": {

        "adultscore": "0.xxx",

        "a": "False",

        "racyscore": "0.xxx",

        "r": "True"

        },

        "ReviewerResultTags": {

        "a": "False",

        "r": "True"

        }

        }

.

        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_id: str
        :param timescale: Timescale of the video you are adding frames to.
        :type timescale: int
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.add_video_frame.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if timescale is not None:
            query_parameters['timescale'] = self._serialize.query("timescale", timescale, 'int')

        # Construct headers
        header_parameters = {}
        if custom_headers:
            header_parameters.update(custom_headers)

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    add_video_frame.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/frames'}

    def get_video_frames(
            self, team_name, review_id, start_seed=None, no_of_records=None, filter=None, custom_headers=None, raw=False, **operation_config):
        """The reviews created would show up for Reviewers on your team. As
        Reviewers complete reviewing, results of the Review would be POSTED
        (i.e. HTTP POST) on the specified CallBackEndpoint.

CallBack Schemas

Review Completion CallBack Sample

        {

        "ReviewId": "<Review Id>",

        "ModifiedOn": "2016-10-11T22:36:32.9934851Z",

        "ModifiedBy": "<Name of the Reviewer>",

        "CallBackType": "Review",

        "ContentId": "<The ContentId that was specified input>",

        "Metadata": {

        "adultscore": "0.xxx",

        "a": "False",

        "racyscore": "0.xxx",

        "r": "True"

        },

        "ReviewerResultTags": {

        "a": "False",

        "r": "True"

        }

        }

.

        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_id: str
        :param start_seed: Time stamp of the frame from where you want to
         start fetching the frames.
        :type start_seed: int
        :param no_of_records: Number of frames to fetch.
        :type no_of_records: int
        :param filter: Get frames filtered by tags.
        :type filter: 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: Frames or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.vision.contentmoderator.models.Frames
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.get_video_frames.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if start_seed is not None:
            query_parameters['startSeed'] = self._serialize.query("start_seed", start_seed, 'int')
        if no_of_records is not None:
            query_parameters['noOfRecords'] = self._serialize.query("no_of_records", no_of_records, 'int')
        if filter is not None:
            query_parameters['filter'] = self._serialize.query("filter", filter, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized
    get_video_frames.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/frames'}

    def publish_video_review(
            self, team_name, review_id, custom_headers=None, raw=False, **operation_config):
        """Publish video review to make it available for review.

        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_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:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.publish_video_review.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        if custom_headers:
            header_parameters.update(custom_headers)

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    publish_video_review.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/publish'}

    def add_video_transcript_moderation_result(
            self, content_type, team_name, review_id, transcript_moderation_body, custom_headers=None, raw=False, **operation_config):
        """This API adds a transcript screen text result file for a video review.
        Transcript screen text result file is a result of Screen Text API . In
        order to generate transcript screen text result file , a transcript
        file has to be screened for profanity using Screen Text API.

        :param content_type: The content type.
        :type content_type: str
        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_id: str
        :param transcript_moderation_body: Body for add video transcript
         moderation result API
        :type transcript_moderation_body:
         list[~azure.cognitiveservices.vision.contentmoderator.models.TranscriptModerationBodyItem]
        :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:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.add_video_transcript_moderation_result.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_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 custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

        # Construct body
        body_content = self._serialize.body(transcript_moderation_body, '[TranscriptModerationBodyItem]')

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

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    add_video_transcript_moderation_result.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/transcriptmoderationresult'}

    def add_video_transcript(
            self, team_name, review_id, vt_tfile, custom_headers=None, raw=False, callback=None, **operation_config):
        """This API adds a transcript file (text version of all the words spoken
        in a video) to a video review. The file should be a valid WebVTT
        format.

        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_id: str
        :param vt_tfile: Transcript file of the video.
        :type vt_tfile: Generator
        :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: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.add_video_transcript.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

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

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

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

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    add_video_transcript.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/transcript'}

    def create_video_reviews(
            self, content_type, team_name, create_video_reviews_body, sub_team=None, custom_headers=None, raw=False, **operation_config):
        """The reviews created would show up for Reviewers on your team. As
        Reviewers complete reviewing, results of the Review would be POSTED
        (i.e. HTTP POST) on the specified CallBackEndpoint.

CallBack Schemas

Review Completion CallBack Sample

        {

        "ReviewId": "<Review Id>",

        "ModifiedOn": "2016-10-11T22:36:32.9934851Z",

        "ModifiedBy": "<Name of the Reviewer>",

        "CallBackType": "Review",

        "ContentId": "<The ContentId that was specified input>",

        "Metadata": {

        "adultscore": "0.xxx",

        "a": "False",

        "racyscore": "0.xxx",

        "r": "True"

        },

        "ReviewerResultTags": {

        "a": "False",

        "r": "True"

        }

        }

.

        :param content_type: The content type.
        :type content_type: str
        :param team_name: Your team name.
        :type team_name: str
        :param create_video_reviews_body: Body for create reviews API
        :type create_video_reviews_body:
         list[~azure.cognitiveservices.vision.contentmoderator.models.CreateVideoReviewsBodyItem]
        :param sub_team: SubTeam of your team, you want to assign the created
         review to.
        :type sub_team: 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: list or ClientRawResponse if raw=true
        :rtype: list[str] or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.create_video_reviews.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if sub_team is not None:
            query_parameters['subTeam'] = self._serialize.query("sub_team", sub_team, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

        # Construct body
        body_content = self._serialize.body(create_video_reviews_body, '[CreateVideoReviewsBodyItem]')

        # 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('[str]', response)

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

        return deserialized
    create_video_reviews.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews'}

    def add_video_frame_url(
            self, content_type, team_name, review_id, video_frame_body, timescale=None, custom_headers=None, raw=False, **operation_config):
        """Use this method to add frames for a video review.Timescale: This
        parameter is a factor which is used to convert the timestamp on a frame
        into milliseconds. Timescale is provided in the output of the Content
        Moderator video media processor on the Azure Media Services
        platform.Timescale in the Video Moderation output is Ticks/Second.

        :param content_type: The content type.
        :type content_type: str
        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_id: str
        :param video_frame_body: Body for add video frames API
        :type video_frame_body:
         list[~azure.cognitiveservices.vision.contentmoderator.models.VideoFrameBodyItem]
        :param timescale: Timescale of the video.
        :type timescale: int
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.add_video_frame_url.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if timescale is not None:
            query_parameters['timescale'] = self._serialize.query("timescale", timescale, 'int')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

        # Construct body
        body_content = self._serialize.body(video_frame_body, '[VideoFrameBodyItem]')

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    add_video_frame_url.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/frames'}

    def add_video_frame_stream(
            self, content_type, team_name, review_id, frame_image_zip, frame_metadata, timescale=None, custom_headers=None, raw=False, **operation_config):
        """Use this method to add frames for a video review.Timescale: This
        parameter is a factor which is used to convert the timestamp on a frame
        into milliseconds. Timescale is provided in the output of the Content
        Moderator video media processor on the Azure Media Services
        platform.Timescale in the Video Moderation output is Ticks/Second.

        :param content_type: The content type.
        :type content_type: str
        :param team_name: Your team name.
        :type team_name: str
        :param review_id: Id of the review.
        :type review_id: str
        :param frame_image_zip: Zip file containing frame images.
        :type frame_image_zip: Generator
        :param frame_metadata: Metadata of the frame.
        :type frame_metadata: str
        :param timescale: Timescale of the video .
        :type timescale: int
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`APIErrorException<azure.cognitiveservices.vision.contentmoderator.models.APIErrorException>`
        """
        # Construct URL
        url = self.add_video_frame_stream.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'teamName': self._serialize.url("team_name", team_name, 'str'),
            'reviewId': self._serialize.url("review_id", review_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if timescale is not None:
            query_parameters['timescale'] = self._serialize.query("timescale", timescale, 'int')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')

        # Construct form data
        form_data_content = {
            'frameImageZip': frame_image_zip,
            'frameMetadata': frame_metadata,
        }

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

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    add_video_frame_stream.metadata = {'url': '/contentmoderator/review/v1.0/teams/{teamName}/reviews/{reviewId}/frames'}