コード例 #1
0
class SwaggerPetstore(object):
    """This is a sample server Petstore server.  You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on irc.freenode.net, #swagger.  For this sample, you can use the api key "special-key" to test the authorization filters

    :ivar config: Configuration for client.
    :vartype config: SwaggerPetstoreConfiguration

    :param str base_url: Service URL
    :param str filepath: Existing config
    """

    def __init__(
            self, base_url=None, filepath=None):

        self.config = SwaggerPetstoreConfiguration(base_url, filepath)
        self._client = ServiceClient(None, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def add_pet_using_byte_array(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Fake endpoint to test byte array in body parameter for adding a new
        pet to the store.

        :param body: Pet object in the form of byte array
        :type body: 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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'str')
        else:
            body_content = None

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

        if response.status_code not in [405]:
            raise HttpOperationError(self._deserialize, response)

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

    def add_pet(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Add a new pet to the store.

        Adds a new pet to the store. You may receive an HTTP invalid input if
        your pet is invalid.

        :param body: Pet object that needs to be added to the store
        :type body: :class:`Pet <Petstore.models.Pet>`
        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Pet')
        else:
            body_content = None

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

        if response.status_code not in [405]:
            raise HttpOperationError(self._deserialize, response)

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

    def update_pet(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Update an existing pet.

        :param body: Pet object that needs to be added to the store
        :type body: :class:`Pet <Petstore.models.Pet>`
        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Pet')
        else:
            body_content = None

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

        if response.status_code not in [405, 404, 400]:
            raise HttpOperationError(self._deserialize, response)

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

    def find_pets_by_status(
            self, status=None, custom_headers=None, raw=False, **operation_config):
        """Finds Pets by status.

        Multiple status values can be provided with comma seperated strings.

        :param status: Status values that need to be considered for filter
        :type status: list of 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>`.
        :rtype: list of :class:`Pet <Petstore.models.Pet>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/findByStatus'

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

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('[Pet]', response)

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

        return deserialized

    def find_pets_by_tags(
            self, tags=None, custom_headers=None, raw=False, **operation_config):
        """Finds Pets by tags.

        Muliple tags can be provided with comma seperated strings. Use tag1,
        tag2, tag3 for testing.

        :param tags: Tags to filter by
        :type tags: list of 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>`.
        :rtype: list of :class:`Pet <Petstore.models.Pet>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/findByTags'

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

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('[Pet]', response)

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

        return deserialized

    def find_pets_with_byte_array(
            self, pet_id, custom_headers=None, raw=False, **operation_config):
        """Fake endpoint to test byte array return by 'Find pet by ID'.

        Returns a pet when ID < 10.  ID > 10 or nonintegers will simulate API
        error conditions.

        :param pet_id: ID of pet that needs to be fetched
        :type pet_id: long
        :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>`.
        :rtype: str
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/{petId}'
        path_format_arguments = {
            'petId': self._serialize.url("pet_id", pet_id, 'long')
        }
        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)

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

        if response.status_code not in [404, 200, 400]:
            raise HttpOperationError(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

    def get_pet_by_id(
            self, pet_id, custom_headers=None, raw=False, **operation_config):
        """Find pet by ID.

        Returns a pet when ID < 10.  ID > 10 or nonintegers will simulate API
        error conditions.

        :param pet_id: ID of pet that needs to be fetched
        :type pet_id: long
        :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>`.
        :rtype: :class:`Pet <Petstore.models.Pet>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/{petId}'
        path_format_arguments = {
            'petId': self._serialize.url("pet_id", pet_id, 'long')
        }
        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)

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

        if response.status_code not in [404, 200, 400]:
            raise HttpOperationError(self._deserialize, response)

        deserialized = None

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

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

        return deserialized

    def update_pet_with_form(
            self, pet_id, name=None, status=None, custom_headers=None, raw=False, **operation_config):
        """Updates a pet in the store with form data.

        :param pet_id: ID of pet that needs to be updated
        :type pet_id: str
        :param name: Updated name of the pet
        :type name: str
        :param status: Updated status of the pet
        :type status: 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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/{petId}'
        path_format_arguments = {
            'petId': self._serialize.url("pet_id", pet_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/x-www-form-urlencoded'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct form data
        form_data_content = {
            'name': name,
            'status': status,
        }

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

        if response.status_code not in [405]:
            raise HttpOperationError(self._deserialize, response)

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

    def delete_pet(
            self, pet_id, api_key=None, custom_headers=None, raw=False, **operation_config):
        """Deletes a pet.

        :param pet_id: Pet id to delete
        :type pet_id: long
        :param api_key:
        :type api_key: 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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/{petId}'
        path_format_arguments = {
            'petId': self._serialize.url("pet_id", pet_id, 'long')
        }
        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)
        if api_key is not None:
            header_parameters['api_key'] = self._serialize.header("api_key", api_key, 'str')

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

        if response.status_code not in [400]:
            raise HttpOperationError(self._deserialize, response)

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

    def upload_file(
            self, pet_id, additional_metadata=None, file=None, custom_headers=None, raw=False, **operation_config):
        """uploads an image.

        :param pet_id: ID of pet to update
        :type pet_id: long
        :param additional_metadata: Additional data to pass to server
        :type additional_metadata: str
        :param file: file to upload
        :type file: 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 operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/pet/{petId}/uploadImage'
        path_format_arguments = {
            'petId': self._serialize.url("pet_id", pet_id, 'long')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct form data
        form_data_content = {
            'additionalMetadata': additional_metadata,
            'file': file,
        }

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

        if response.status_code < 200 or response.status_code >= 300:
            raise HttpOperationError(self._deserialize, response)

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

    def get_inventory(
            self, custom_headers=None, raw=False, **operation_config):
        """Returns pet inventories by status.

        Returns a map of status codes to quantities.

        :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>`.
        :rtype: dict
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/store/inventory'

        # 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)

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

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('{int}', response)

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

        return deserialized

    def place_order(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Place an order for a pet.

        :param body: order placed for purchasing the pet
        :type body: :class:`Order <Petstore.models.Order>`
        :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>`.
        :rtype: :class:`Order <Petstore.models.Order>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/store/order'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Order')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized

    def get_order_by_id(
            self, order_id, custom_headers=None, raw=False, **operation_config):
        """Find purchase order by ID.

        For valid response try integer IDs with value <= 5 or > 10. Other
        values will generated exceptions.

        :param order_id: ID of pet that needs to be fetched
        :type order_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>`.
        :rtype: :class:`Order <Petstore.models.Order>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/store/order/{orderId}'
        path_format_arguments = {
            'orderId': self._serialize.url("order_id", order_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)

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

        if response.status_code not in [404, 200, 400]:
            raise HttpOperationError(self._deserialize, response)

        deserialized = None

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

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

        return deserialized

    def delete_order(
            self, order_id, custom_headers=None, raw=False, **operation_config):
        """Delete purchase order by ID.

        For valid response try integer IDs with value < 1000. Anything above
        1000 or nonintegers will generate API errors.

        :param order_id: ID of the order that needs to be deleted
        :type order_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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/store/order/{orderId}'
        path_format_arguments = {
            'orderId': self._serialize.url("order_id", order_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)

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

        if response.status_code not in [404, 400]:
            raise HttpOperationError(self._deserialize, response)

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

    def create_user(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Create user.

        This can only be done by the logged in user.

        :param body: Created user object
        :type body: :class:`User <Petstore.models.User>`
        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'User')
        else:
            body_content = None

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

        if response.status_code < 200 or response.status_code >= 300:
            raise HttpOperationError(self._deserialize, response)

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

    def create_users_with_array_input(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Creates list of users with given input array.

        :param body: List of user object
        :type body: list of :class:`User <Petstore.models.User>`
        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/createWithArray'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, '[User]')
        else:
            body_content = None

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

        if response.status_code < 200 or response.status_code >= 300:
            raise HttpOperationError(self._deserialize, response)

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

    def create_users_with_list_input(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """Creates list of users with given input array.

        :param body: List of user object
        :type body: list of :class:`User <Petstore.models.User>`
        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/createWithList'

        # 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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, '[User]')
        else:
            body_content = None

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

        if response.status_code < 200 or response.status_code >= 300:
            raise HttpOperationError(self._deserialize, response)

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

    def login_user(
            self, username=None, password=None, custom_headers=None, raw=False, **operation_config):
        """Logs user into the system.

        :param username: The user name for login
        :type username: str
        :param password: The password for login in clear text
        :type password: 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>`.
        :rtype: str
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/login'

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

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

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

        if response.status_code not in [200, 400]:
            raise HttpOperationError(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

    def logout_user(
            self, custom_headers=None, raw=False, **operation_config):
        """Logs out current logged in user session.

        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/logout'

        # 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)

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

        if response.status_code < 200 or response.status_code >= 300:
            raise HttpOperationError(self._deserialize, response)

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

    def get_user_by_name(
            self, username, custom_headers=None, raw=False, **operation_config):
        """Get user by user name.

        :param username: The name that needs to be fetched. Use user1 for
         testing.
        :type username: 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>`.
        :rtype: :class:`User <Petstore.models.User>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/{username}'
        path_format_arguments = {
            'username': self._serialize.url("username", username, '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)

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

        if response.status_code not in [404, 200, 400]:
            raise HttpOperationError(self._deserialize, response)

        deserialized = None

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

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

        return deserialized

    def update_user(
            self, username, body=None, custom_headers=None, raw=False, **operation_config):
        """Updated user.

        This can only be done by the logged in user.

        :param username: name that need to be deleted
        :type username: str
        :param body: Updated user object
        :type body: :class:`User <Petstore.models.User>`
        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/{username}'
        path_format_arguments = {
            'username': self._serialize.url("username", username, '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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'User')
        else:
            body_content = None

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

        if response.status_code not in [404, 400]:
            raise HttpOperationError(self._deserialize, response)

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

    def delete_user(
            self, username, custom_headers=None, raw=False, **operation_config):
        """Delete user.

        This can only be done by the logged in user.

        :param username: The name that needs to be deleted
        :type username: 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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/user/{username}'
        path_format_arguments = {
            'username': self._serialize.url("username", username, '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)

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

        if response.status_code not in [404, 400]:
            raise HttpOperationError(self._deserialize, response)

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
コード例 #2
0
class AutoSuggestSearchAPI(SDKClient):
    """The AutoSuggest Search API lets you send a search query to Bing and get back a list of news that are relevant to the search query. This section provides technical details about the query parameters and headers that you use to request news and the JSON response objects that contain them. For examples that show how to make requests, see [Searching the web for AutoSuggest](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference).

    :ivar config: Configuration for client.
    :vartype config: AutoSuggestSearchAPIConfiguration

    :param credentials: Subscription credentials which uniquely identify
     client subscription.
    :type credentials: None
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, base_url=None):

        self.config = AutoSuggestSearchAPIConfiguration(credentials, base_url)
        super(AutoSuggestSearchAPI, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '1.0'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def auto_suggest(
            self, query, accept_language=None, pragma=None, user_agent=None, client_id=None, client_ip=None, location=None, country_code=None, market="en-us", safe_search=None, set_lang=None, response_format=None, custom_headers=None, raw=False, **operation_config):
        """The AutoSuggest API lets you send a search query to Bing and get back a
        list of suggestions. This section provides technical details about the
        query parameters and headers that you use to request suggestions and
        the JSON response objects that contain them.

        :param query: The user's search term.
        :type query: str
        :param accept_language: A comma-delimited list of one or more
         languages to use for user interface strings. The list is in decreasing
         order of preference. For additional information, including expected
         format, see
         [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
         This header and the setLang query parameter are mutually exclusive; do
         not specify both. If you set this header, you must also specify the
         [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc)
         query parameter. To determine the market to return results for, Bing
         uses the first supported language it finds from the list and combines
         it with the cc parameter value. If the list does not include a
         supported language, Bing finds the closest language and market that
         supports the request or it uses an aggregated or default market for
         the results. To determine the market that Bing used, see the
         BingAPIs-Market header. Use this header and the cc query parameter
         only if you specify multiple languages. Otherwise, use the
         [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt)
         and
         [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang)
         query parameters. A user interface string is a string that's used as a
         label in a user interface. There are few user interface strings in the
         JSON response objects. Any links to Bing.com properties in the
         response objects apply the specified language.
        :type accept_language: str
        :param pragma: By default, Bing returns cached content, if available.
         To prevent Bing from returning cached content, set the Pragma header
         to no-cache (for example, Pragma: no-cache).
        :type pragma: str
        :param user_agent: The user agent originating the request. Bing uses
         the user agent to provide mobile users with an optimized experience.
         Although optional, you are encouraged to always specify this header.
         The user-agent should be the same string that any commonly used
         browser sends. For information about user agents, see [RFC
         2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The
         following are examples of user-agent strings. Windows Phone:
         Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0;
         IEMobile/10.0; ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0
         (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / GINGERBREAD)
         AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari /
         533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X)
         AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 iPhone4; 1
         BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3;
         WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0
         (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like
         Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53
        :type user_agent: str
        :param client_id: Bing uses this header to provide users with
         consistent behavior across Bing API calls. Bing often flights new
         features and improvements, and it uses the client ID as a key for
         assigning traffic on different flights. If you do not use the same
         client ID for a user across multiple requests, then Bing may assign
         the user to multiple conflicting flights. Being assigned to multiple
         conflicting flights can lead to an inconsistent user experience. For
         example, if the second request has a different flight assignment than
         the first, the experience may be unexpected. Also, Bing can use the
         client ID to tailor web results to that client ID’s search history,
         providing a richer experience for the user. Bing also uses this header
         to help improve result rankings by analyzing the activity generated by
         a client ID. The relevance improvements help with better quality of
         results delivered by Bing APIs and in turn enables higher
         click-through rates for the API consumer. IMPORTANT: Although
         optional, you should consider this header required. Persisting the
         client ID across multiple requests for the same end user and device
         combination enables 1) the API consumer to receive a consistent user
         experience, and 2) higher click-through rates via better quality of
         results from the Bing APIs. Each user that uses your application on
         the device must have a unique, Bing generated client ID. If you do not
         include this header in the request, Bing generates an ID and returns
         it in the X-MSEdge-ClientID response header. The only time that you
         should NOT include this header in a request is the first time the user
         uses your app on that device. Use the client ID for each Bing API
         request that your app makes for this user on the device. Persist the
         client ID. To persist the ID in a browser app, use a persistent HTTP
         cookie to ensure the ID is used across all sessions. Do not use a
         session cookie. For other apps such as mobile apps, use the device's
         persistent storage to persist the ID. The next time the user uses your
         app on that device, get the client ID that you persisted. Bing
         responses may or may not include this header. If the response includes
         this header, capture the client ID and use it for all subsequent Bing
         requests for the user on that device. If you include the
         X-MSEdge-ClientID, you must not include cookies in the request.
        :type client_id: str
        :param client_ip: The IPv4 or IPv6 address of the client device. The
         IP address is used to discover the user's location. Bing uses the
         location information to determine safe search behavior. Although
         optional, you are encouraged to always specify this header and the
         X-Search-Location header. Do not obfuscate the address (for example,
         by changing the last octet to 0). Obfuscating the address results in
         the location not being anywhere near the device's actual location,
         which may result in Bing serving erroneous results.
        :type client_ip: str
        :param location: A semicolon-delimited list of key/value pairs that
         describe the client's geographical location. Bing uses the location
         information to determine safe search behavior and to return relevant
         local content. Specify the key/value pair as <key>:<value>. The
         following are the keys that you use to specify the user's location.
         lat (required): The latitude of the client's location, in degrees. The
         latitude must be greater than or equal to -90.0 and less than or equal
         to +90.0. Negative values indicate southern latitudes and positive
         values indicate northern latitudes. long (required): The longitude of
         the client's location, in degrees. The longitude must be greater than
         or equal to -180.0 and less than or equal to +180.0. Negative values
         indicate western longitudes and positive values indicate eastern
         longitudes. re (required): The radius, in meters, which specifies the
         horizontal accuracy of the coordinates. Pass the value returned by the
         device's location service. Typical values might be 22m for GPS/Wi-Fi,
         380m for cell tower triangulation, and 18,000m for reverse IP lookup.
         ts (optional): The UTC UNIX timestamp of when the client was at the
         location. (The UNIX timestamp is the number of seconds since January
         1, 1970.) head (optional): The client's relative heading or direction
         of travel. Specify the direction of travel as degrees from 0 through
         360, counting clockwise relative to true north. Specify this key only
         if the sp key is nonzero. sp (optional): The horizontal velocity
         (speed), in meters per second, that the client device is traveling.
         alt (optional): The altitude of the client device, in meters. are
         (optional): The radius, in meters, that specifies the vertical
         accuracy of the coordinates. Specify this key only if you specify the
         alt key. Although many of the keys are optional, the more information
         that you provide, the more accurate the location results are. Although
         optional, you are encouraged to always specify the user's geographical
         location. Providing the location is especially important if the
         client's IP address does not accurately reflect the user's physical
         location (for example, if the client uses VPN). For optimal results,
         you should include this header and the X-MSEdge-ClientIP header, but
         at a minimum, you should include this header.
        :type location: str
        :param country_code: A 2-character country code of the country where
         the results come from. This API supports only the United States
         market. If you specify this query parameter, it must be set to us. If
         you set this parameter, you must also specify the Accept-Language
         header. Bing uses the first supported language it finds from the
         languages list, and combine that language with the country code that
         you specify to determine the market to return results for. If the
         languages list does not include a supported language, Bing finds the
         closest language and market that supports the request, or it may use
         an aggregated or default market for the results instead of a specified
         one. You should use this query parameter and the Accept-Language query
         parameter only if you specify multiple languages; otherwise, you
         should use the mkt and setLang query parameters. This parameter and
         the mkt query parameter are mutually exclusive—do not specify both.
        :type country_code: str
        :param market: The market where the results come from. You are
         strongly encouraged to always specify the market, if known. Specifying
         the market helps Bing route the request and return an appropriate and
         optimal response. This parameter and the cc query parameter are
         mutually exclusive—do not specify both.
        :type market: str
        :param safe_search: Filter suggestions for adult content. The
         following are the possible filter values. Off: Return suggestions with
         adult text, images, or videos. Moderate: Return suggestion with adult
         text but not adult images or videos. Strict: Do not return news
         articles with adult text, images, or videos. If the request comes from
         a market that Bing's adult policy requires that safeSearch is set to
         Strict, Bing ignores the safeSearch value and uses Strict. If you use
         the site: query operator, there is the chance that the response may
         contain adult content regardless of what the safeSearch query
         parameter is set to. Use site: only if you are aware of the content on
         the site and your scenario supports the possibility of adult content.
         Possible values include: 'Off', 'Moderate', 'Strict'
        :type safe_search: str or
         ~azure.cognitiveservices.search.autosuggest.models.SafeSearch
        :param set_lang: The language to use for user interface strings.
         Specify the language using the ISO 639-1 2-letter language code. For
         example, the language code for English is EN. The default is EN
         (English). Although optional, you should always specify the language.
         Typically, you set setLang to the same language specified by mkt
         unless the user wants the user interface strings displayed in a
         different language. This parameter and the Accept-Language header are
         mutually exclusive; do not specify both. A user interface string is a
         string that's used as a label in a user interface. There are few user
         interface strings in the JSON response objects. Also, any links to
         Bing.com properties in the response objects apply the specified
         language.
        :type set_lang: str
        :param response_format: The media type to use for the response. The
         following are the possible case-insensitive values: JSON, JSONLD. The
         default is JSON. If you specify JSONLD, the response body includes
         JSON-LD objects that contain the search results.
        :type response_format: list[str or
         ~azure.cognitiveservices.search.autosuggest.models.ResponseFormat]
        :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: Suggestions or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.search.autosuggest.models.Suggestions
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.search.autosuggest.models.ErrorResponseException>`
        """
        x_bing_apis_sdk = "true"

        # Construct URL
        url = self.auto_suggest.metadata['url']

        # Construct parameters
        query_parameters = {}
        if country_code is not None:
            query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str')
        if market is not None:
            query_parameters['mkt'] = self._serialize.query("market", market, 'str')
        query_parameters['q'] = self._serialize.query("query", query, 'str')
        if safe_search is not None:
            query_parameters['safeSearch'] = self._serialize.query("safe_search", safe_search, 'str')
        if set_lang is not None:
            query_parameters['setLang'] = self._serialize.query("set_lang", set_lang, 'str')
        if response_format is not None:
            query_parameters['ResponseFormat'] = self._serialize.query("response_format", response_format, '[str]', div=',')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['X-BingApis-SDK'] = self._serialize.header("x_bing_apis_sdk", x_bing_apis_sdk, 'str')
        if accept_language is not None:
            header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str')
        if pragma is not None:
            header_parameters['Pragma'] = self._serialize.header("pragma", pragma, 'str')
        if user_agent is not None:
            header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str')
        if client_id is not None:
            header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str')
        if client_ip is not None:
            header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str')
        if location is not None:
            header_parameters['X-Search-Location'] = self._serialize.header("location", location, '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.ErrorResponseException(self._deserialize, response)

        deserialized = None

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

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

        return deserialized
    auto_suggest.metadata = {'url': '/Suggestions'}
コード例 #3
0
class LogicManagementClient(object):
    """REST API for Azure Logic Apps.

    :ivar config: Configuration for client.
    :vartype config: LogicManagementClientConfiguration

    :ivar workflows: Workflows operations
    :vartype workflows: .operations.WorkflowsOperations
    :ivar workflow_versions: WorkflowVersions operations
    :vartype workflow_versions: .operations.WorkflowVersionsOperations
    :ivar workflow_triggers: WorkflowTriggers operations
    :vartype workflow_triggers: .operations.WorkflowTriggersOperations
    :ivar workflow_trigger_histories: WorkflowTriggerHistories operations
    :vartype workflow_trigger_histories: .operations.WorkflowTriggerHistoriesOperations
    :ivar workflow_runs: WorkflowRuns operations
    :vartype workflow_runs: .operations.WorkflowRunsOperations
    :ivar workflow_run_actions: WorkflowRunActions operations
    :vartype workflow_run_actions: .operations.WorkflowRunActionsOperations
    :ivar integration_accounts: IntegrationAccounts operations
    :vartype integration_accounts: .operations.IntegrationAccountsOperations
    :ivar schemas: Schemas operations
    :vartype schemas: .operations.SchemasOperations
    :ivar maps: Maps operations
    :vartype maps: .operations.MapsOperations
    :ivar partners: Partners operations
    :vartype partners: .operations.PartnersOperations
    :ivar agreements: Agreements operations
    :vartype agreements: .operations.AgreementsOperations
    :ivar certificates: Certificates operations
    :vartype certificates: .operations.CertificatesOperations
    :ivar sessions: Sessions operations
    :vartype sessions: .operations.SessionsOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription id.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = LogicManagementClientConfiguration(credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2016-06-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.workflows = WorkflowsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_versions = WorkflowVersionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_triggers = WorkflowTriggersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_trigger_histories = WorkflowTriggerHistoriesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_runs = WorkflowRunsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_run_actions = WorkflowRunActionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.integration_accounts = IntegrationAccountsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.schemas = SchemasOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.maps = MapsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.partners = PartnersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.agreements = AgreementsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.certificates = CertificatesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.sessions = SessionsOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def list_operations(
            self, custom_headers=None, raw=False, **operation_config):
        """Lists all of the available Logic REST API operations.

        :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>`.
        :rtype: :class:`OperationPaged
         <azure.mgmt.logic.models.OperationPaged>`
        :raises:
         :class:`ErrorResponseException<azure.mgmt.logic.models.ErrorResponseException>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Logic/operations'

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized
コード例 #4
0
class CdnManagementClient(object):
    """Use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must make sure that requests made to these resources are secure.

    :ivar config: Configuration for client.
    :vartype config: CdnManagementClientConfiguration

    :ivar profiles: Profiles operations
    :vartype profiles: azure.mgmt.cdn.operations.ProfilesOperations
    :ivar endpoints: Endpoints operations
    :vartype endpoints: azure.mgmt.cdn.operations.EndpointsOperations
    :ivar origins: Origins operations
    :vartype origins: azure.mgmt.cdn.operations.OriginsOperations
    :ivar custom_domains: CustomDomains operations
    :vartype custom_domains: azure.mgmt.cdn.operations.CustomDomainsOperations
    :ivar resource_usage: ResourceUsage operations
    :vartype resource_usage: azure.mgmt.cdn.operations.ResourceUsageOperations
    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.cdn.operations.Operations
    :ivar edge_nodes: EdgeNodes operations
    :vartype edge_nodes: azure.mgmt.cdn.operations.EdgeNodesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Azure Subscription ID.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = CdnManagementClientConfiguration(credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2017-04-02'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.profiles = ProfilesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.endpoints = EndpointsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.origins = OriginsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.custom_domains = CustomDomainsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.resource_usage = ResourceUsageOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)
        self.edge_nodes = EdgeNodesOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_name_availability(
            self, name, custom_headers=None, raw=False, **operation_config):
        """Check the availability of a resource name. This is needed for resources
        where name is globally unique, such as a CDN endpoint.

        :param name: The resource name to validate.
        :type name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: CheckNameAvailabilityOutput or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>`
        """
        check_name_availability_input = models.CheckNameAvailabilityInput(name=name)

        # Construct URL
        url = self.check_name_availability.metadata['url']

        # 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(check_name_availability_input, 'CheckNameAvailabilityInput')

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

        deserialized = None

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

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

        return deserialized
    check_name_availability.metadata = {'url': '/providers/Microsoft.Cdn/checkNameAvailability'}

    def validate_probe(
            self, probe_url, custom_headers=None, raw=False, **operation_config):
        """Check if the probe path is a valid path and the file can be accessed.
        Probe path is the path to a file hosted on the origin server to help
        accelerate the delivery of dynamic content via the CDN endpoint. This
        path is relative to the origin path specified in the endpoint
        configuration.

        :param probe_url: The probe URL to validate.
        :type probe_url: 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: ValidateProbeOutput or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>`
        """
        validate_probe_input = models.ValidateProbeInput(probe_url=probe_url)

        # Construct URL
        url = self.validate_probe.metadata['url']
        path_format_arguments = {
            '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 = {}
        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(validate_probe_input, 'ValidateProbeInput')

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

        deserialized = None

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

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

        return deserialized
    validate_probe.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe'}
コード例 #5
0
class AutoRestValidationTest(object):
    """Test Infrastructure for AutoRest. No server backend exists for these tests.

    :ivar config: Configuration for client.
    :vartype config: AutoRestValidationTestConfiguration

    :param subscription_id: Subscription ID.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, subscription_id, base_url=None):

        self.config = AutoRestValidationTestConfiguration(subscription_id, base_url)
        self._client = ServiceClient(None, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '1.0.0'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def validation_of_method_parameters(
            self, resource_group_name, id, custom_headers=None, raw=False, **operation_config):
        """Validates input parameters on the method. See swagger for details.

        :param resource_group_name: Required string between 3 and 10 chars
         with pattern [a-zA-Z0-9]+.
        :type resource_group_name: str
        :param id: Required int multiple of 10 from 100 to 1000.
        :type id: 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: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises:
         :class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>`
        """
        # Construct URL
        url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
        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', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'),
            'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['apiVersion'] = self._serialize.query("self.api_version", self.api_version, 'str', pattern=r'\d{2}-\d{2}-\d{4}')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized

    def validation_of_body(
            self, resource_group_name, id, body=None, custom_headers=None, raw=False, **operation_config):
        """Validates body parameters on the method. See swagger for details.

        :param resource_group_name: Required string between 3 and 10 chars
         with pattern [a-zA-Z0-9]+.
        :type resource_group_name: str
        :param id: Required int multiple of 10 from 100 to 1000.
        :type id: int
        :param body:
        :type body: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>`
        :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: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises:
         :class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>`
        """
        # Construct URL
        url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
        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', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'),
            'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['apiVersion'] = self._serialize.query("self.api_version", self.api_version, 'str', pattern=r'\d{2}-\d{2}-\d{4}')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Product')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized

    def get_with_constant_in_path(
            self, custom_headers=None, raw=False, **operation_config):
        """

        :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
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: None or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        constant_param = "constant"

        # Construct URL
        url = '/validation/constantsInPath/{constantParam}/value'
        path_format_arguments = {
            'constantParam': self._serialize.url("constant_param", constant_param, '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)

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

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

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

    def post_with_constant_in_body(
            self, body=None, custom_headers=None, raw=False, **operation_config):
        """

        :param body:
        :type body: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>`
        :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: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: :class:`Product
         <fixtures.acceptancetestsvalidation.models.Product>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        constant_param = "constant"

        # Construct URL
        url = '/validation/constantsInPath/{constantParam}/value'
        path_format_arguments = {
            'constantParam': self._serialize.url("constant_param", constant_param, '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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Product')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized
コード例 #6
0
class FeatureClient(SDKClient):
    """Azure Feature Exposure Control (AFEC) provides a mechanism for the resource providers to control feature exposure to users. Resource providers typically use this mechanism to provide public/private preview for new features prior to making them generally available. Users need to explicitly register for AFEC features to get access to such functionality.

    :ivar config: Configuration for client.
    :vartype config: FeatureClientConfiguration

    :ivar features: Features operations
    :vartype features: azure.mgmt.resource.features.v2015_12_01.operations.FeaturesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The ID of the target subscription.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = FeatureClientConfiguration(credentials, subscription_id, base_url)
        super(FeatureClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2015-12-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.features = FeaturesOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def list_operations(
            self, custom_headers=None, raw=False, **operation_config):
        """Lists all of the available Microsoft.Features REST API operations.

        :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 Operation
        :rtype:
         ~azure.mgmt.resource.features.v2015_12_01.models.OperationPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        def internal_paging(next_link=None, raw=False):

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

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

            else:
                url = next_link
                query_parameters = {}

            # Construct headers
            header_parameters = {}
            header_parameters['Accept'] = 'application/json'
            if self.config.generate_client_request_id:
                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
            if custom_headers:
                header_parameters.update(custom_headers)
            if self.config.accept_language is not None:
                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

            if response.status_code not in [200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            return response

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

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

        return deserialized
    list_operations.metadata = {'url': '/providers/Microsoft.Features/operations'}
コード例 #7
0
class SecurityClient(Client):
    """Security
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """

    def __init__(self, base_url=None, creds=None):
        super(SecurityClient, self).__init__(base_url, creds)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def remove_access_control_entries(self, security_namespace_id, token=None, descriptors=None):
        """RemoveAccessControlEntries.
        Remove the specified ACEs from the ACL belonging to the specified token.
        :param str security_namespace_id: Security namespace identifier.
        :param str token: The token whose ACL should be modified.
        :param str descriptors: String containing a list of identity descriptors separated by ',' whose entries should be removed.
        :rtype: bool
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if token is not None:
            query_parameters['token'] = self._serialize.query('token', token, 'str')
        if descriptors is not None:
            query_parameters['descriptors'] = self._serialize.query('descriptors', descriptors, 'str')
        response = self._send(http_method='DELETE',
                              location_id='ac08c8ff-4323-4b08-af90-bcd018d380ce',
                              version='5.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('bool', response)

    def set_access_control_entries(self, container, security_namespace_id):
        """SetAccessControlEntries.
        Add or update ACEs in the ACL for the provided token. The request body contains the target token, a list of [ACEs](https://docs.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20entries/set%20access%20control%20entries?#accesscontrolentry) and a optional merge parameter. In the case of a collision (by identity descriptor) with an existing ACE in the ACL, the "merge" parameter determines the behavior. If set, the existing ACE has its allow and deny merged with the incoming ACE's allow and deny. If unset, the existing ACE is displaced.
        :param :class:`<object> <azure.devops.v5_1.security.models.object>` container:
        :param str security_namespace_id: Security namespace identifier.
        :rtype: [AccessControlEntry]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        content = self._serialize.body(container, 'object')
        response = self._send(http_method='POST',
                              location_id='ac08c8ff-4323-4b08-af90-bcd018d380ce',
                              version='5.1',
                              route_values=route_values,
                              content=content)
        return self._deserialize('[AccessControlEntry]', self._unwrap_collection(response))

    def query_access_control_lists(self, security_namespace_id, token=None, descriptors=None, include_extended_info=None, recurse=None):
        """QueryAccessControlLists.
        Return a list of access control lists for the specified security namespace and token. All ACLs in the security namespace will be retrieved if no optional parameters are provided.
        :param str security_namespace_id: Security namespace identifier.
        :param str token: Security token
        :param str descriptors: An optional filter string containing a list of identity descriptors separated by ',' whose ACEs should be retrieved. If this is left null, entire ACLs will be returned.
        :param bool include_extended_info: If true, populate the extended information properties for the access control entries contained in the returned lists.
        :param bool recurse: If true and this is a hierarchical namespace, return child ACLs of the specified token.
        :rtype: [AccessControlList]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if token is not None:
            query_parameters['token'] = self._serialize.query('token', token, 'str')
        if descriptors is not None:
            query_parameters['descriptors'] = self._serialize.query('descriptors', descriptors, 'str')
        if include_extended_info is not None:
            query_parameters['includeExtendedInfo'] = self._serialize.query('include_extended_info', include_extended_info, 'bool')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        response = self._send(http_method='GET',
                              location_id='18a2ad18-7571-46ae-bec7-0c7da1495885',
                              version='5.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('[AccessControlList]', self._unwrap_collection(response))

    def remove_access_control_lists(self, security_namespace_id, tokens=None, recurse=None):
        """RemoveAccessControlLists.
        Remove access control lists under the specfied security namespace.
        :param str security_namespace_id: Security namespace identifier.
        :param str tokens: One or more comma-separated security tokens
        :param bool recurse: If true and this is a hierarchical namespace, also remove child ACLs of the specified tokens.
        :rtype: bool
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if tokens is not None:
            query_parameters['tokens'] = self._serialize.query('tokens', tokens, 'str')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        response = self._send(http_method='DELETE',
                              location_id='18a2ad18-7571-46ae-bec7-0c7da1495885',
                              version='5.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('bool', response)

    def set_access_control_lists(self, access_control_lists, security_namespace_id):
        """SetAccessControlLists.
        Create or update one or more access control lists. All data that currently exists for the ACLs supplied will be overwritten.
        :param :class:`<VssJsonCollectionWrapper> <azure.devops.v5_1.security.models.VssJsonCollectionWrapper>` access_control_lists: A list of ACLs to create or update.
        :param str security_namespace_id: Security namespace identifier.
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        content = self._serialize.body(access_control_lists, 'VssJsonCollectionWrapper')
        self._send(http_method='POST',
                   location_id='18a2ad18-7571-46ae-bec7-0c7da1495885',
                   version='5.1',
                   route_values=route_values,
                   content=content)

    def has_permissions_batch(self, eval_batch):
        """HasPermissionsBatch.
        Evaluates multiple permissions for the calling user.  Note: This method does not aggregate the results, nor does it short-circuit if one of the permissions evaluates to false.
        :param :class:`<PermissionEvaluationBatch> <azure.devops.v5_1.security.models.PermissionEvaluationBatch>` eval_batch: The set of evaluation requests.
        :rtype: :class:`<PermissionEvaluationBatch> <azure.devops.v5_1.security.models.PermissionEvaluationBatch>`
        """
        content = self._serialize.body(eval_batch, 'PermissionEvaluationBatch')
        response = self._send(http_method='POST',
                              location_id='cf1faa59-1b63-4448-bf04-13d981a46f5d',
                              version='5.1',
                              content=content)
        return self._deserialize('PermissionEvaluationBatch', response)

    def has_permissions(self, security_namespace_id, permissions=None, tokens=None, always_allow_administrators=None, delimiter=None):
        """HasPermissions.
        Evaluates whether the caller has the specified permissions on the specified set of security tokens.
        :param str security_namespace_id: Security namespace identifier.
        :param int permissions: Permissions to evaluate.
        :param str tokens: One or more security tokens to evaluate.
        :param bool always_allow_administrators: If true and if the caller is an administrator, always return true.
        :param str delimiter: Optional security token separator. Defaults to ",".
        :rtype: [bool]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        if permissions is not None:
            route_values['permissions'] = self._serialize.url('permissions', permissions, 'int')
        query_parameters = {}
        if tokens is not None:
            query_parameters['tokens'] = self._serialize.query('tokens', tokens, 'str')
        if always_allow_administrators is not None:
            query_parameters['alwaysAllowAdministrators'] = self._serialize.query('always_allow_administrators', always_allow_administrators, 'bool')
        if delimiter is not None:
            query_parameters['delimiter'] = self._serialize.query('delimiter', delimiter, 'str')
        response = self._send(http_method='GET',
                              location_id='dd3b8bd6-c7fc-4cbd-929a-933d9c011c9d',
                              version='5.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('[bool]', self._unwrap_collection(response))

    def remove_permission(self, security_namespace_id, descriptor, permissions=None, token=None):
        """RemovePermission.
        Removes the specified permissions on a security token for a user or group.
        :param str security_namespace_id: Security namespace identifier.
        :param str descriptor: Identity descriptor of the user to remove permissions for.
        :param int permissions: Permissions to remove.
        :param str token: Security token to remove permissions for.
        :rtype: :class:`<AccessControlEntry> <azure.devops.v5_1.security.models.AccessControlEntry>`
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        if permissions is not None:
            route_values['permissions'] = self._serialize.url('permissions', permissions, 'int')
        query_parameters = {}
        if descriptor is not None:
            query_parameters['descriptor'] = self._serialize.query('descriptor', descriptor, 'str')
        if token is not None:
            query_parameters['token'] = self._serialize.query('token', token, 'str')
        response = self._send(http_method='DELETE',
                              location_id='dd3b8bd6-c7fc-4cbd-929a-933d9c011c9d',
                              version='5.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('AccessControlEntry', response)

    def query_security_namespaces(self, security_namespace_id=None, local_only=None):
        """QuerySecurityNamespaces.
        List all security namespaces or just the specified namespace.
        :param str security_namespace_id: Security namespace identifier.
        :param bool local_only: If true, retrieve only local security namespaces.
        :rtype: [SecurityNamespaceDescription]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if local_only is not None:
            query_parameters['localOnly'] = self._serialize.query('local_only', local_only, 'bool')
        response = self._send(http_method='GET',
                              location_id='ce7b9f95-fde9-4be8-a86d-83b366f0b87a',
                              version='5.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('[SecurityNamespaceDescription]', self._unwrap_collection(response))
class AzureNetAppFilesManagementClient(SDKClient):
    """Microsoft NetApp Azure Resource Provider specification

    :ivar config: Configuration for client.
    :vartype config: AzureNetAppFilesManagementClientConfiguration

    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.netapp.operations.Operations
    :ivar accounts: Accounts operations
    :vartype accounts: azure.mgmt.netapp.operations.AccountsOperations
    :ivar pools: Pools operations
    :vartype pools: azure.mgmt.netapp.operations.PoolsOperations
    :ivar volumes: Volumes operations
    :vartype volumes: azure.mgmt.netapp.operations.VolumesOperations
    :ivar mount_targets: MountTargets operations
    :vartype mount_targets: azure.mgmt.netapp.operations.MountTargetsOperations
    :ivar snapshots: Snapshots operations
    :vartype snapshots: azure.mgmt.netapp.operations.SnapshotsOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Subscription credentials which uniquely identify
     Microsoft Azure subscription. The subscription ID forms part of the URI
     for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = AzureNetAppFilesManagementClientConfiguration(credentials, subscription_id, base_url)
        super(AzureNetAppFilesManagementClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2019-05-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)
        self.accounts = AccountsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.pools = PoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.volumes = VolumesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.mount_targets = MountTargetsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.snapshots = SnapshotsOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_name_availability(
            self, location, custom_headers=None, raw=False, **operation_config):
        """Check resource name availability.

        Check if a resource name is available.

        :param location: The location
        :type location: 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: ResourceNameAvailability or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.netapp.models.ResourceNameAvailability or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = self.check_name_availability.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'location': self._serialize.url("location", location, '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['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]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
    check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkNameAvailability'}

    def check_file_path_availability(
            self, location, custom_headers=None, raw=False, **operation_config):
        """Check file path availability.

        Check if a file path is available.

        :param location: The location
        :type location: 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: ResourceNameAvailability or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.netapp.models.ResourceNameAvailability or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = self.check_file_path_availability.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'location': self._serialize.url("location", location, '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['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]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
    check_file_path_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkFilePathAvailability'}
コード例 #9
0
class PolicyClient(VssClient):
    """Policy
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(PolicyClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = 'fb13a388-40dd-4a04-b530-013a739c72ef'

    def create_policy_configuration(self,
                                    configuration,
                                    project,
                                    configuration_id=None):
        """CreatePolicyConfiguration.
        Create a policy configuration of a given policy type.
        :param :class:`<PolicyConfiguration> <policy.v4_1.models.PolicyConfiguration>` configuration: The policy configuration to create.
        :param str project: Project ID or project name
        :param int configuration_id:
        :rtype: :class:`<PolicyConfiguration> <policy.v4_1.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        content = self._serialize.body(configuration, 'PolicyConfiguration')
        response = self._send(
            http_method='POST',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='4.1',
            route_values=route_values,
            content=content)
        return self._deserialize('PolicyConfiguration', response)

    def delete_policy_configuration(self, project, configuration_id):
        """DeletePolicyConfiguration.
        Delete a policy configuration by its ID.
        :param str project: Project ID or project name
        :param int configuration_id: ID of the policy configuration to delete.
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        self._send(http_method='DELETE',
                   location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
                   version='4.1',
                   route_values=route_values)

    def get_policy_configuration(self, project, configuration_id):
        """GetPolicyConfiguration.
        Get a policy configuration by its ID.
        :param str project: Project ID or project name
        :param int configuration_id: ID of the policy configuration
        :rtype: :class:`<PolicyConfiguration> <policy.v4_1.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='4.1',
            route_values=route_values)
        return self._deserialize('PolicyConfiguration', response)

    def get_policy_configurations(self, project, scope=None, policy_type=None):
        """GetPolicyConfigurations.
        Get a list of policy configurations in a project.
        :param str project: Project ID or project name
        :param str scope: The scope on which a subset of policies is applied.
        :param str policy_type: Filter returned policies to only this type
        :rtype: [PolicyConfiguration]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if scope is not None:
            query_parameters['scope'] = self._serialize.query(
                'scope', scope, 'str')
        if policy_type is not None:
            query_parameters['policyType'] = self._serialize.query(
                'policy_type', policy_type, 'str')
        response = self._send(
            http_method='GET',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='4.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[PolicyConfiguration]', response)

    def update_policy_configuration(self, configuration, project,
                                    configuration_id):
        """UpdatePolicyConfiguration.
        Update a policy configuration by its ID.
        :param :class:`<PolicyConfiguration> <policy.v4_1.models.PolicyConfiguration>` configuration: The policy configuration to update.
        :param str project: Project ID or project name
        :param int configuration_id: ID of the existing policy configuration to be updated.
        :rtype: :class:`<PolicyConfiguration> <policy.v4_1.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        content = self._serialize.body(configuration, 'PolicyConfiguration')
        response = self._send(
            http_method='PUT',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='4.1',
            route_values=route_values,
            content=content)
        return self._deserialize('PolicyConfiguration', response)

    def get_policy_evaluation(self, project, evaluation_id):
        """GetPolicyEvaluation.
        [Preview API] Gets the present evaluation state of a policy.
        :param str project: Project ID or project name
        :param str evaluation_id: ID of the policy evaluation to be retrieved.
        :rtype: :class:`<PolicyEvaluationRecord> <policy.v4_1.models.PolicyEvaluationRecord>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if evaluation_id is not None:
            route_values['evaluationId'] = self._serialize.url(
                'evaluation_id', evaluation_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='46aecb7a-5d2c-4647-897b-0209505a9fe4',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('PolicyEvaluationRecord', response)

    def requeue_policy_evaluation(self, project, evaluation_id):
        """RequeuePolicyEvaluation.
        [Preview API] Requeue the policy evaluation.
        :param str project: Project ID or project name
        :param str evaluation_id: ID of the policy evaluation to be retrieved.
        :rtype: :class:`<PolicyEvaluationRecord> <policy.v4_1.models.PolicyEvaluationRecord>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if evaluation_id is not None:
            route_values['evaluationId'] = self._serialize.url(
                'evaluation_id', evaluation_id, 'str')
        response = self._send(
            http_method='PATCH',
            location_id='46aecb7a-5d2c-4647-897b-0209505a9fe4',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('PolicyEvaluationRecord', response)

    def get_policy_evaluations(self,
                               project,
                               artifact_id,
                               include_not_applicable=None,
                               top=None,
                               skip=None):
        """GetPolicyEvaluations.
        [Preview API] Retrieves a list of all the policy evaluation statuses for a specific pull request.
        :param str project: Project ID or project name
        :param str artifact_id: A string which uniquely identifies the target of a policy evaluation.
        :param bool include_not_applicable: Some policies might determine that they do not apply to a specific pull request. Setting this parameter to true will return evaluation records even for policies which don't apply to this pull request.
        :param int top: The number of policy evaluation records to retrieve.
        :param int skip: The number of policy evaluation records to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
        :rtype: [PolicyEvaluationRecord]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if artifact_id is not None:
            query_parameters['artifactId'] = self._serialize.query(
                'artifact_id', artifact_id, 'str')
        if include_not_applicable is not None:
            query_parameters['includeNotApplicable'] = self._serialize.query(
                'include_not_applicable', include_not_applicable, 'bool')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='c23ddff5-229c-4d04-a80b-0fdce9f360c8',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[PolicyEvaluationRecord]', response)

    def get_policy_configuration_revision(self, project, configuration_id,
                                          revision_id):
        """GetPolicyConfigurationRevision.
        Retrieve a specific revision of a given policy by ID.
        :param str project: Project ID or project name
        :param int configuration_id: The policy configuration ID.
        :param int revision_id: The revision ID.
        :rtype: :class:`<PolicyConfiguration> <policy.v4_1.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        if revision_id is not None:
            route_values['revisionId'] = self._serialize.url(
                'revision_id', revision_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='fe1e68a2-60d3-43cb-855b-85e41ae97c95',
            version='4.1',
            route_values=route_values)
        return self._deserialize('PolicyConfiguration', response)

    def get_policy_configuration_revisions(self,
                                           project,
                                           configuration_id,
                                           top=None,
                                           skip=None):
        """GetPolicyConfigurationRevisions.
        Retrieve all revisions for a given policy.
        :param str project: Project ID or project name
        :param int configuration_id: The policy configuration ID.
        :param int top: The number of revisions to retrieve.
        :param int skip: The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
        :rtype: [PolicyConfiguration]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='fe1e68a2-60d3-43cb-855b-85e41ae97c95',
            version='4.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[PolicyConfiguration]', response)

    def get_policy_type(self, project, type_id):
        """GetPolicyType.
        Retrieve a specific policy type by ID.
        :param str project: Project ID or project name
        :param str type_id: The policy ID.
        :rtype: :class:`<PolicyType> <policy.v4_1.models.PolicyType>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if type_id is not None:
            route_values['typeId'] = self._serialize.url(
                'type_id', type_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
            version='4.1',
            route_values=route_values)
        return self._deserialize('PolicyType', response)

    def get_policy_types(self, project):
        """GetPolicyTypes.
        Retrieve all available policy types.
        :param str project: Project ID or project name
        :rtype: [PolicyType]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        response = self._send(
            http_method='GET',
            location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
            version='4.1',
            route_values=route_values,
            returns_collection=True)
        return self._deserialize('[PolicyType]', response)
コード例 #10
0
class AzureNetAppFilesManagementClient(SDKClient):
    """Microsoft NetApp Azure Resource Provider specification

    :ivar config: Configuration for client.
    :vartype config: AzureNetAppFilesManagementClientConfiguration

    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.netapp.operations.Operations
    :ivar accounts: Accounts operations
    :vartype accounts: azure.mgmt.netapp.operations.AccountsOperations
    :ivar pools: Pools operations
    :vartype pools: azure.mgmt.netapp.operations.PoolsOperations
    :ivar volumes: Volumes operations
    :vartype volumes: azure.mgmt.netapp.operations.VolumesOperations
    :ivar mount_targets: MountTargets operations
    :vartype mount_targets: azure.mgmt.netapp.operations.MountTargetsOperations
    :ivar snapshots: Snapshots operations
    :vartype snapshots: azure.mgmt.netapp.operations.SnapshotsOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Subscription credentials which uniquely identify
     Microsoft Azure subscription. The subscription ID forms part of the URI
     for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """
    def __init__(self, credentials, subscription_id, base_url=None):

        self.config = AzureNetAppFilesManagementClientConfiguration(
            credentials, subscription_id, base_url)
        super(AzureNetAppFilesManagementClient,
              self).__init__(self.config.credentials, self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self.api_version = '2019-06-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.operations = Operations(self._client, self.config,
                                     self._serialize, self._deserialize)
        self.accounts = AccountsOperations(self._client, self.config,
                                           self._serialize, self._deserialize)
        self.pools = PoolsOperations(self._client, self.config,
                                     self._serialize, self._deserialize)
        self.volumes = VolumesOperations(self._client, self.config,
                                         self._serialize, self._deserialize)
        self.mount_targets = MountTargetsOperations(self._client, self.config,
                                                    self._serialize,
                                                    self._deserialize)
        self.snapshots = SnapshotsOperations(self._client, self.config,
                                             self._serialize,
                                             self._deserialize)

    def check_name_availability(self,
                                location,
                                name,
                                type,
                                resource_group,
                                custom_headers=None,
                                raw=False,
                                **operation_config):
        """Check resource name availability.

        Check if a resource name is available.

        :param location: The location
        :type location: str
        :param name: Resource name to verify.
        :type name: str
        :param type: Resource type used for verification. Possible values
         include: 'Microsoft.NetApp/netAppAccounts',
         'Microsoft.NetApp/netAppAccounts/capacityPools',
         'Microsoft.NetApp/netAppAccounts/capacityPools/volumes',
         'Microsoft.NetApp/netAppAccounts/capacityPools/volumes/snapshots'
        :type type: str or ~azure.mgmt.netapp.models.CheckNameResourceTypes
        :param resource_group: Resource group name.
        :type resource_group: 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: ResourceNameAvailability or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.netapp.models.ResourceNameAvailability or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        body = models.ResourceNameAvailabilityRequest(
            name=name, type=type, resource_group=resource_group)

        # Construct URL
        url = self.check_name_availability.metadata['url']
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str'),
            'location':
            self._serialize.url("location", location, '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['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

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

        # 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

        deserialized = None

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

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

        return deserialized

    check_name_availability.metadata = {
        'url':
        '/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkNameAvailability'
    }

    def check_file_path_availability(self,
                                     location,
                                     name,
                                     type,
                                     resource_group,
                                     custom_headers=None,
                                     raw=False,
                                     **operation_config):
        """Check file path availability.

        Check if a file path is available.

        :param location: The location
        :type location: str
        :param name: Resource name to verify.
        :type name: str
        :param type: Resource type used for verification. Possible values
         include: 'Microsoft.NetApp/netAppAccounts',
         'Microsoft.NetApp/netAppAccounts/capacityPools',
         'Microsoft.NetApp/netAppAccounts/capacityPools/volumes',
         'Microsoft.NetApp/netAppAccounts/capacityPools/volumes/snapshots'
        :type type: str or ~azure.mgmt.netapp.models.CheckNameResourceTypes
        :param resource_group: Resource group name.
        :type resource_group: 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: ResourceNameAvailability or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.netapp.models.ResourceNameAvailability or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        body = models.ResourceNameAvailabilityRequest(
            name=name, type=type, resource_group=resource_group)

        # Construct URL
        url = self.check_file_path_availability.metadata['url']
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("self.config.subscription_id",
                                self.config.subscription_id, 'str'),
            'location':
            self._serialize.url("location", location, '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['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

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

        # 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

        deserialized = None

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

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

        return deserialized

    check_file_path_availability.metadata = {
        'url':
        '/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkFilePathAvailability'
    }
コード例 #11
0
class FeedClient(Client):
    """Feed
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(FeedClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '7ab4e64e-c4d8-4f50-ae73-5ef2e21642a5'

    def get_badge(self, feed_id, package_id):
        """GetBadge.
        [Preview API] Generate a SVG badge for the latest version of a package.  The generated SVG is typically used as the image in an HTML link which takes users to the feed containing the package to accelerate discovery and consumption.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: Id of the package (GUID Id, not name).
        :rtype: str
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='61d885fd-10f3-4a55-82b6-476d866b673f',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('str', response)

    def get_feed_change(self, feed_id):
        """GetFeedChange.
        [Preview API] Query a feed to determine its current state.
        :param str feed_id: Name or ID of the feed.
        :rtype: :class:`<FeedChange> <azure.devops.v5_1.feed.models.FeedChange>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='29ba2dad-389a-4661-b5d3-de76397ca05b',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('FeedChange', response)

    def get_feed_changes(self,
                         include_deleted=None,
                         continuation_token=None,
                         batch_size=None):
        """GetFeedChanges.
        [Preview API] Query to determine which feeds have changed since the last call, tracked through the provided continuationToken. Only changes to a feed itself are returned and impact the continuationToken, not additions or alterations to packages within the feeds.
        :param bool include_deleted: If true, get changes for all feeds including deleted feeds. The default value is false.
        :param long continuation_token: A continuation token which acts as a bookmark to a previously retrieved change. This token allows the user to continue retrieving changes in batches, picking up where the previous batch left off. If specified, all the changes that occur strictly after the token will be returned. If not specified or 0, iteration will start with the first change.
        :param int batch_size: Number of package changes to fetch. The default value is 1000. The maximum value is 2000.
        :rtype: :class:`<FeedChangesResponse> <azure.devops.v5_1.feed.models.FeedChangesResponse>`
        """
        query_parameters = {}
        if include_deleted is not None:
            query_parameters['includeDeleted'] = self._serialize.query(
                'include_deleted', include_deleted, 'bool')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'long')
        if batch_size is not None:
            query_parameters['batchSize'] = self._serialize.query(
                'batch_size', batch_size, 'int')
        response = self._send(
            http_method='GET',
            location_id='29ba2dad-389a-4661-b5d3-de76397ca05b',
            version='5.1-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('FeedChangesResponse', response)

    def create_feed(self, feed):
        """CreateFeed.
        [Preview API] Create a feed, a container for various package types.
        :param :class:`<Feed> <azure.devops.v5_1.feed.models.Feed>` feed: A JSON object containing both required and optional attributes for the feed. Name is the only required value.
        :rtype: :class:`<Feed> <azure.devops.v5_1.feed.models.Feed>`
        """
        content = self._serialize.body(feed, 'Feed')
        response = self._send(
            http_method='POST',
            location_id='c65009a7-474a-4ad1-8b42-7d852107ef8c',
            version='5.1-preview.1',
            content=content)
        return self._deserialize('Feed', response)

    def delete_feed(self, feed_id):
        """DeleteFeed.
        [Preview API] Remove a feed and all its packages.  The action does not result in packages moving to the RecycleBin and is not reversible.
        :param str feed_id: Name or Id of the feed.
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        self._send(http_method='DELETE',
                   location_id='c65009a7-474a-4ad1-8b42-7d852107ef8c',
                   version='5.1-preview.1',
                   route_values=route_values)

    def get_feed(self, feed_id, include_deleted_upstreams=None):
        """GetFeed.
        [Preview API] Get the settings for a specific feed.
        :param str feed_id: Name or Id of the feed.
        :param bool include_deleted_upstreams: Include upstreams that have been deleted in the response.
        :rtype: :class:`<Feed> <azure.devops.v5_1.feed.models.Feed>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        query_parameters = {}
        if include_deleted_upstreams is not None:
            query_parameters[
                'includeDeletedUpstreams'] = self._serialize.query(
                    'include_deleted_upstreams', include_deleted_upstreams,
                    'bool')
        response = self._send(
            http_method='GET',
            location_id='c65009a7-474a-4ad1-8b42-7d852107ef8c',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('Feed', response)

    def get_feeds(self, feed_role=None, include_deleted_upstreams=None):
        """GetFeeds.
        [Preview API] Get all feeds in an account where you have the provided role access.
        :param str feed_role: Filter by this role, either Administrator(4), Contributor(3), or Reader(2) level permissions.
        :param bool include_deleted_upstreams: Include upstreams that have been deleted in the response.
        :rtype: [Feed]
        """
        query_parameters = {}
        if feed_role is not None:
            query_parameters['feedRole'] = self._serialize.query(
                'feed_role', feed_role, 'str')
        if include_deleted_upstreams is not None:
            query_parameters[
                'includeDeletedUpstreams'] = self._serialize.query(
                    'include_deleted_upstreams', include_deleted_upstreams,
                    'bool')
        response = self._send(
            http_method='GET',
            location_id='c65009a7-474a-4ad1-8b42-7d852107ef8c',
            version='5.1-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[Feed]', self._unwrap_collection(response))

    def update_feed(self, feed, feed_id):
        """UpdateFeed.
        [Preview API] Change the attributes of a feed.
        :param :class:`<FeedUpdate> <azure.devops.v5_1.feed.models.FeedUpdate>` feed: A JSON object containing the feed settings to be updated.
        :param str feed_id: Name or Id of the feed.
        :rtype: :class:`<Feed> <azure.devops.v5_1.feed.models.Feed>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        content = self._serialize.body(feed, 'FeedUpdate')
        response = self._send(
            http_method='PATCH',
            location_id='c65009a7-474a-4ad1-8b42-7d852107ef8c',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Feed', response)

    def get_global_permissions(self):
        """GetGlobalPermissions.
        [Preview API] Get all service-wide feed creation and administration permissions.
        :rtype: [GlobalPermission]
        """
        response = self._send(
            http_method='GET',
            location_id='a74419ef-b477-43df-8758-3cd1cd5f56c6',
            version='5.1-preview.1')
        return self._deserialize('[GlobalPermission]',
                                 self._unwrap_collection(response))

    def set_global_permissions(self, global_permissions):
        """SetGlobalPermissions.
        [Preview API] Set service-wide permissions that govern feed creation and administration.
        :param [GlobalPermission] global_permissions: New permissions for the organization.
        :rtype: [GlobalPermission]
        """
        content = self._serialize.body(global_permissions,
                                       '[GlobalPermission]')
        response = self._send(
            http_method='PATCH',
            location_id='a74419ef-b477-43df-8758-3cd1cd5f56c6',
            version='5.1-preview.1',
            content=content)
        return self._deserialize('[GlobalPermission]',
                                 self._unwrap_collection(response))

    def get_package_changes(self,
                            feed_id,
                            continuation_token=None,
                            batch_size=None):
        """GetPackageChanges.
        [Preview API] Get a batch of package changes made to a feed.  The changes returned are 'most recent change' so if an Add is followed by an Update before you begin enumerating, you'll only see one change in the batch.  While consuming batches using the continuation token, you may see changes to the same package version multiple times if they are happening as you enumerate.
        :param str feed_id: Name or Id of the feed.
        :param long continuation_token: A continuation token which acts as a bookmark to a previously retrieved change. This token allows the user to continue retrieving changes in batches, picking up where the previous batch left off. If specified, all the changes that occur strictly after the token will be returned. If not specified or 0, iteration will start with the first change.
        :param int batch_size: Number of package changes to fetch. The default value is 1000. The maximum value is 2000.
        :rtype: :class:`<PackageChangesResponse> <azure.devops.v5_1.feed.models.PackageChangesResponse>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        query_parameters = {}
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'long')
        if batch_size is not None:
            query_parameters['batchSize'] = self._serialize.query(
                'batch_size', batch_size, 'int')
        response = self._send(
            http_method='GET',
            location_id='323a0631-d083-4005-85ae-035114dfb681',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('PackageChangesResponse', response)

    def query_package_metrics(self, package_id_query, feed_id):
        """QueryPackageMetrics.
        [Preview API]
        :param :class:`<PackageMetricsQuery> <azure.devops.v5_1.feed.models.PackageMetricsQuery>` package_id_query:
        :param str feed_id:
        :rtype: [PackageMetrics]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        content = self._serialize.body(package_id_query, 'PackageMetricsQuery')
        response = self._send(
            http_method='POST',
            location_id='bddc9b3c-8a59-4a9f-9b40-ee1dcaa2cc0d',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[PackageMetrics]',
                                 self._unwrap_collection(response))

    def get_package(self,
                    feed_id,
                    package_id,
                    include_all_versions=None,
                    include_urls=None,
                    is_listed=None,
                    is_release=None,
                    include_deleted=None,
                    include_description=None):
        """GetPackage.
        [Preview API] Get details about a specific package.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: The package Id (GUID Id, not the package name).
        :param bool include_all_versions: True to return all versions of the package in the response.  Default is false (latest version only).
        :param bool include_urls: True to return REST Urls with the response.  Default is True.
        :param bool is_listed: Only applicable for NuGet packages, setting it for other package types will result in a 404.  If false, delisted package versions will be returned. Use this to filter the response when includeAllVersions is set to true.  Default is unset (do not return delisted packages).
        :param bool is_release: Only applicable for Nuget packages.  Use this to filter the response when includeAllVersions is set to true.  Default is True (only return packages without prerelease versioning).
        :param bool include_deleted: Return deleted or unpublished versions of packages in the response. Default is False.
        :param bool include_description: Return the description for every version of each package in the response.  Default is False.
        :rtype: :class:`<Package> <azure.devops.v5_1.feed.models.Package>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        query_parameters = {}
        if include_all_versions is not None:
            query_parameters['includeAllVersions'] = self._serialize.query(
                'include_all_versions', include_all_versions, 'bool')
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        if is_listed is not None:
            query_parameters['isListed'] = self._serialize.query(
                'is_listed', is_listed, 'bool')
        if is_release is not None:
            query_parameters['isRelease'] = self._serialize.query(
                'is_release', is_release, 'bool')
        if include_deleted is not None:
            query_parameters['includeDeleted'] = self._serialize.query(
                'include_deleted', include_deleted, 'bool')
        if include_description is not None:
            query_parameters['includeDescription'] = self._serialize.query(
                'include_description', include_description, 'bool')
        response = self._send(
            http_method='GET',
            location_id='7a20d846-c929-4acc-9ea2-0d5a7df1b197',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('Package', response)

    def get_packages(self,
                     feed_id,
                     protocol_type=None,
                     package_name_query=None,
                     normalized_package_name=None,
                     include_urls=None,
                     include_all_versions=None,
                     is_listed=None,
                     get_top_package_versions=None,
                     is_release=None,
                     include_description=None,
                     top=None,
                     skip=None,
                     include_deleted=None,
                     is_cached=None,
                     direct_upstream_id=None):
        """GetPackages.
        [Preview API] Get details about all of the packages in the feed.  Use the various filters to include or exclude information from the result set.
        :param str feed_id: Name or Id of the feed.
        :param str protocol_type: One of the supported artifact package types.
        :param str package_name_query: Filter to packages that contain the provided string.  Characters in the string must conform to the package name constraints.
        :param str normalized_package_name: [Obsolete] Used for legacy scenarios and may be removed in future versions.
        :param bool include_urls: True to return REST Urls with the response.  Default is True.
        :param bool include_all_versions: True to return all versions of the package in the response.  Default is false (latest version only).
        :param bool is_listed: Only applicable for NuGet packages, setting it for other package types will result in a 404.  If false, delisted package versions will be returned. Use this to filter the response when includeAllVersions is set to true.  Default is unset (do not return delisted packages).
        :param bool get_top_package_versions: Changes the behavior of $top and $skip to return all versions of each package up to $top. Must be used in conjunction with includeAllVersions=true
        :param bool is_release: Only applicable for Nuget packages.  Use this to filter the response when includeAllVersions is set to true.  Default is True (only return packages without prerelease versioning).
        :param bool include_description: Return the description for every version of each package in the response.  Default is False.
        :param int top: Get the top N packages (or package versions where getTopPackageVersions=true)
        :param int skip: Skip the first N packages (or package versions where getTopPackageVersions=true)
        :param bool include_deleted: Return deleted or unpublished versions of packages in the response. Default is False.
        :param bool is_cached: [Obsolete]  Used for legacy scenarios and may be removed in future versions.
        :param str direct_upstream_id: Filter results to return packages from a specific upstream.
        :rtype: [Package]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        query_parameters = {}
        if protocol_type is not None:
            query_parameters['protocolType'] = self._serialize.query(
                'protocol_type', protocol_type, 'str')
        if package_name_query is not None:
            query_parameters['packageNameQuery'] = self._serialize.query(
                'package_name_query', package_name_query, 'str')
        if normalized_package_name is not None:
            query_parameters['normalizedPackageName'] = self._serialize.query(
                'normalized_package_name', normalized_package_name, 'str')
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        if include_all_versions is not None:
            query_parameters['includeAllVersions'] = self._serialize.query(
                'include_all_versions', include_all_versions, 'bool')
        if is_listed is not None:
            query_parameters['isListed'] = self._serialize.query(
                'is_listed', is_listed, 'bool')
        if get_top_package_versions is not None:
            query_parameters['getTopPackageVersions'] = self._serialize.query(
                'get_top_package_versions', get_top_package_versions, 'bool')
        if is_release is not None:
            query_parameters['isRelease'] = self._serialize.query(
                'is_release', is_release, 'bool')
        if include_description is not None:
            query_parameters['includeDescription'] = self._serialize.query(
                'include_description', include_description, 'bool')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        if include_deleted is not None:
            query_parameters['includeDeleted'] = self._serialize.query(
                'include_deleted', include_deleted, 'bool')
        if is_cached is not None:
            query_parameters['isCached'] = self._serialize.query(
                'is_cached', is_cached, 'bool')
        if direct_upstream_id is not None:
            query_parameters['directUpstreamId'] = self._serialize.query(
                'direct_upstream_id', direct_upstream_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='7a20d846-c929-4acc-9ea2-0d5a7df1b197',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[Package]',
                                 self._unwrap_collection(response))

    def get_feed_permissions(self,
                             feed_id,
                             include_ids=None,
                             exclude_inherited_permissions=None,
                             identity_descriptor=None):
        """GetFeedPermissions.
        [Preview API] Get the permissions for a feed.
        :param str feed_id: Name or Id of the feed.
        :param bool include_ids: True to include user Ids in the response.  Default is false.
        :param bool exclude_inherited_permissions: True to only return explicitly set permissions on the feed.  Default is false.
        :param str identity_descriptor: Filter permissions to the provided identity.
        :rtype: [FeedPermission]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        query_parameters = {}
        if include_ids is not None:
            query_parameters['includeIds'] = self._serialize.query(
                'include_ids', include_ids, 'bool')
        if exclude_inherited_permissions is not None:
            query_parameters[
                'excludeInheritedPermissions'] = self._serialize.query(
                    'exclude_inherited_permissions',
                    exclude_inherited_permissions, 'bool')
        if identity_descriptor is not None:
            query_parameters['identityDescriptor'] = self._serialize.query(
                'identity_descriptor', identity_descriptor, 'str')
        response = self._send(
            http_method='GET',
            location_id='be8c1476-86a7-44ed-b19d-aec0e9275cd8',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[FeedPermission]',
                                 self._unwrap_collection(response))

    def set_feed_permissions(self, feed_permission, feed_id):
        """SetFeedPermissions.
        [Preview API] Update the permissions on a feed.
        :param [FeedPermission] feed_permission: Permissions to set.
        :param str feed_id: Name or Id of the feed.
        :rtype: [FeedPermission]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        content = self._serialize.body(feed_permission, '[FeedPermission]')
        response = self._send(
            http_method='PATCH',
            location_id='be8c1476-86a7-44ed-b19d-aec0e9275cd8',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[FeedPermission]',
                                 self._unwrap_collection(response))

    def get_package_version_provenance(self, feed_id, package_id,
                                       package_version_id):
        """GetPackageVersionProvenance.
        [Preview API] Gets provenance for a package version.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: Id of the package (GUID Id, not name).
        :param str package_version_id: Id of the package version (GUID Id, not name).
        :rtype: :class:`<PackageVersionProvenance> <azure.devops.v5_1.feed.models.PackageVersionProvenance>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        if package_version_id is not None:
            route_values['packageVersionId'] = self._serialize.url(
                'package_version_id', package_version_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='0aaeabd4-85cd-4686-8a77-8d31c15690b8',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('PackageVersionProvenance', response)

    def get_recycle_bin_package(self, feed_id, package_id, include_urls=None):
        """GetRecycleBinPackage.
        [Preview API] Get information about a package and all its versions within the recycle bin.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: The package Id (GUID Id, not the package name).
        :param bool include_urls: True to return REST Urls with the response.  Default is True.
        :rtype: :class:`<Package> <azure.devops.v5_1.feed.models.Package>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        query_parameters = {}
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        response = self._send(
            http_method='GET',
            location_id='2704e72c-f541-4141-99be-2004b50b05fa',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('Package', response)

    def get_recycle_bin_packages(self,
                                 feed_id,
                                 protocol_type=None,
                                 package_name_query=None,
                                 include_urls=None,
                                 top=None,
                                 skip=None,
                                 include_all_versions=None):
        """GetRecycleBinPackages.
        [Preview API] Query for packages within the recycle bin.
        :param str feed_id: Name or Id of the feed.
        :param str protocol_type: Type of package (e.g. NuGet, npm, ...).
        :param str package_name_query: Filter to packages matching this name.
        :param bool include_urls: True to return REST Urls with the response.  Default is True.
        :param int top: Get the top N packages.
        :param int skip: Skip the first N packages.
        :param bool include_all_versions: True to return all versions of the package in the response.  Default is false (latest version only).
        :rtype: [Package]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        query_parameters = {}
        if protocol_type is not None:
            query_parameters['protocolType'] = self._serialize.query(
                'protocol_type', protocol_type, 'str')
        if package_name_query is not None:
            query_parameters['packageNameQuery'] = self._serialize.query(
                'package_name_query', package_name_query, 'str')
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        if include_all_versions is not None:
            query_parameters['includeAllVersions'] = self._serialize.query(
                'include_all_versions', include_all_versions, 'bool')
        response = self._send(
            http_method='GET',
            location_id='2704e72c-f541-4141-99be-2004b50b05fa',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[Package]',
                                 self._unwrap_collection(response))

    def get_recycle_bin_package_version(self,
                                        feed_id,
                                        package_id,
                                        package_version_id,
                                        include_urls=None):
        """GetRecycleBinPackageVersion.
        [Preview API] Get information about a package version within the recycle bin.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: The package Id (GUID Id, not the package name).
        :param str package_version_id: The package version Id 9guid Id, not the version string).
        :param bool include_urls: True to return REST Urls with the response.  Default is True.
        :rtype: :class:`<RecycleBinPackageVersion> <azure.devops.v5_1.feed.models.RecycleBinPackageVersion>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        if package_version_id is not None:
            route_values['packageVersionId'] = self._serialize.url(
                'package_version_id', package_version_id, 'str')
        query_parameters = {}
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        response = self._send(
            http_method='GET',
            location_id='aceb4be7-8737-4820-834c-4c549e10fdc7',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('RecycleBinPackageVersion', response)

    def get_recycle_bin_package_versions(self,
                                         feed_id,
                                         package_id,
                                         include_urls=None):
        """GetRecycleBinPackageVersions.
        [Preview API] Get a list of package versions within the recycle bin.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: The package Id (GUID Id, not the package name).
        :param bool include_urls: True to return REST Urls with the response.  Default is True.
        :rtype: [RecycleBinPackageVersion]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        query_parameters = {}
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        response = self._send(
            http_method='GET',
            location_id='aceb4be7-8737-4820-834c-4c549e10fdc7',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[RecycleBinPackageVersion]',
                                 self._unwrap_collection(response))

    def delete_feed_retention_policies(self, feed_id):
        """DeleteFeedRetentionPolicies.
        [Preview API] Delete the retention policy for a feed.
        :param str feed_id: Name or ID of the feed.
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        self._send(http_method='DELETE',
                   location_id='ed52a011-0112-45b5-9f9e-e14efffb3193',
                   version='5.1-preview.1',
                   route_values=route_values)

    def get_feed_retention_policies(self, feed_id):
        """GetFeedRetentionPolicies.
        [Preview API] Get the retention policy for a feed.
        :param str feed_id: Name or ID of the feed.
        :rtype: :class:`<FeedRetentionPolicy> <azure.devops.v5_1.feed.models.FeedRetentionPolicy>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='ed52a011-0112-45b5-9f9e-e14efffb3193',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('FeedRetentionPolicy', response)

    def set_feed_retention_policies(self, policy, feed_id):
        """SetFeedRetentionPolicies.
        [Preview API] Set the retention policy for a feed.
        :param :class:`<FeedRetentionPolicy> <azure.devops.v5_1.feed.models.FeedRetentionPolicy>` policy: Feed retention policy.
        :param str feed_id: Name or ID of the feed.
        :rtype: :class:`<FeedRetentionPolicy> <azure.devops.v5_1.feed.models.FeedRetentionPolicy>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        content = self._serialize.body(policy, 'FeedRetentionPolicy')
        response = self._send(
            http_method='PUT',
            location_id='ed52a011-0112-45b5-9f9e-e14efffb3193',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('FeedRetentionPolicy', response)

    def query_package_version_metrics(self, package_version_id_query, feed_id,
                                      package_id):
        """QueryPackageVersionMetrics.
        [Preview API]
        :param :class:`<PackageVersionMetricsQuery> <azure.devops.v5_1.feed.models.PackageVersionMetricsQuery>` package_version_id_query:
        :param str feed_id:
        :param str package_id:
        :rtype: [PackageVersionMetrics]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        content = self._serialize.body(package_version_id_query,
                                       'PackageVersionMetricsQuery')
        response = self._send(
            http_method='POST',
            location_id='e6ae8caa-b6a8-4809-b840-91b2a42c19ad',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[PackageVersionMetrics]',
                                 self._unwrap_collection(response))

    def get_package_version(self,
                            feed_id,
                            package_id,
                            package_version_id,
                            include_urls=None,
                            is_listed=None,
                            is_deleted=None):
        """GetPackageVersion.
        [Preview API] Get details about a specific package version.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: Id of the package (GUID Id, not name).
        :param str package_version_id: Id of the package version (GUID Id, not name).
        :param bool include_urls: True to include urls for each version.  Default is true.
        :param bool is_listed: Only applicable for NuGet packages.  If false, delisted package versions will be returned.
        :param bool is_deleted: Return deleted or unpublished versions of packages in the response. Default is unset (do not return deleted versions).
        :rtype: :class:`<PackageVersion> <azure.devops.v5_1.feed.models.PackageVersion>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        if package_version_id is not None:
            route_values['packageVersionId'] = self._serialize.url(
                'package_version_id', package_version_id, 'str')
        query_parameters = {}
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        if is_listed is not None:
            query_parameters['isListed'] = self._serialize.query(
                'is_listed', is_listed, 'bool')
        if is_deleted is not None:
            query_parameters['isDeleted'] = self._serialize.query(
                'is_deleted', is_deleted, 'bool')
        response = self._send(
            http_method='GET',
            location_id='3b331909-6a86-44cc-b9ec-c1834c35498f',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('PackageVersion', response)

    def get_package_versions(self,
                             feed_id,
                             package_id,
                             include_urls=None,
                             is_listed=None,
                             is_deleted=None):
        """GetPackageVersions.
        [Preview API] Get a list of package versions, optionally filtering by state.
        :param str feed_id: Name or Id of the feed.
        :param str package_id: Id of the package (GUID Id, not name).
        :param bool include_urls: True to include urls for each version.  Default is true.
        :param bool is_listed: Only applicable for NuGet packages.  If false, delisted package versions will be returned.
        :param bool is_deleted: Return deleted or unpublished versions of packages in the response. Default is unset (do not return deleted versions).
        :rtype: [PackageVersion]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if package_id is not None:
            route_values['packageId'] = self._serialize.url(
                'package_id', package_id, 'str')
        query_parameters = {}
        if include_urls is not None:
            query_parameters['includeUrls'] = self._serialize.query(
                'include_urls', include_urls, 'bool')
        if is_listed is not None:
            query_parameters['isListed'] = self._serialize.query(
                'is_listed', is_listed, 'bool')
        if is_deleted is not None:
            query_parameters['isDeleted'] = self._serialize.query(
                'is_deleted', is_deleted, 'bool')
        response = self._send(
            http_method='GET',
            location_id='3b331909-6a86-44cc-b9ec-c1834c35498f',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[PackageVersion]',
                                 self._unwrap_collection(response))

    def create_feed_view(self, view, feed_id):
        """CreateFeedView.
        [Preview API] Create a new view on the referenced feed.
        :param :class:`<FeedView> <azure.devops.v5_1.feed.models.FeedView>` view: View to be created.
        :param str feed_id: Name or Id of the feed.
        :rtype: :class:`<FeedView> <azure.devops.v5_1.feed.models.FeedView>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        content = self._serialize.body(view, 'FeedView')
        response = self._send(
            http_method='POST',
            location_id='42a8502a-6785-41bc-8c16-89477d930877',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('FeedView', response)

    def delete_feed_view(self, feed_id, view_id):
        """DeleteFeedView.
        [Preview API] Delete a feed view.
        :param str feed_id: Name or Id of the feed.
        :param str view_id: Name or Id of the view.
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if view_id is not None:
            route_values['viewId'] = self._serialize.url(
                'view_id', view_id, 'str')
        self._send(http_method='DELETE',
                   location_id='42a8502a-6785-41bc-8c16-89477d930877',
                   version='5.1-preview.1',
                   route_values=route_values)

    def get_feed_view(self, feed_id, view_id):
        """GetFeedView.
        [Preview API] Get a view by Id.
        :param str feed_id: Name or Id of the feed.
        :param str view_id: Name or Id of the view.
        :rtype: :class:`<FeedView> <azure.devops.v5_1.feed.models.FeedView>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if view_id is not None:
            route_values['viewId'] = self._serialize.url(
                'view_id', view_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='42a8502a-6785-41bc-8c16-89477d930877',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('FeedView', response)

    def get_feed_views(self, feed_id):
        """GetFeedViews.
        [Preview API] Get all views for a feed.
        :param str feed_id: Name or Id of the feed.
        :rtype: [FeedView]
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='42a8502a-6785-41bc-8c16-89477d930877',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('[FeedView]',
                                 self._unwrap_collection(response))

    def update_feed_view(self, view, feed_id, view_id):
        """UpdateFeedView.
        [Preview API] Update a view.
        :param :class:`<FeedView> <azure.devops.v5_1.feed.models.FeedView>` view: New settings to apply to the specified view.
        :param str feed_id: Name or Id of the feed.
        :param str view_id: Name or Id of the view.
        :rtype: :class:`<FeedView> <azure.devops.v5_1.feed.models.FeedView>`
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url(
                'feed_id', feed_id, 'str')
        if view_id is not None:
            route_values['viewId'] = self._serialize.url(
                'view_id', view_id, 'str')
        content = self._serialize.body(view, 'FeedView')
        response = self._send(
            http_method='PATCH',
            location_id='42a8502a-6785-41bc-8c16-89477d930877',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('FeedView', response)
class IntuneResourceManagementClient(object):
    """Microsoft.Intune Resource provider Api features in the swagger-2.0 specification

    :ivar config: Configuration for client.
    :vartype config: IntuneResourceManagementClientConfiguration

    :ivar ios: Ios operations
    :vartype ios: .operations.IosOperations
    :ivar android: Android operations
    :vartype android: .operations.AndroidOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param api_version: Service Api Version.
    :type api_version: str
    :param accept_language: Gets or sets the preferred language for the
     response.
    :type accept_language: str
    :param long_running_operation_retry_timeout: Gets or sets the retry
     timeout in seconds for Long Running Operations. Default value is 30.
    :type long_running_operation_retry_timeout: int
    :param generate_client_request_id: When set to true a unique
     x-ms-client-request-id value is generated and included in each request.
     Default is true.
    :type generate_client_request_id: bool
    :param str base_url: Service URL
    :param str filepath: Existing config
    """

    def __init__(
            self, credentials, api_version='2015-01-14-preview', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):

        self.config = IntuneResourceManagementClientConfiguration(credentials, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.ios = IosOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.android = AndroidOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def get_locations(
            self, custom_headers=None, raw=False, **operation_config):
        """Returns location for user tenant.

        :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>`.
        :rtype: :class:`LocationPaged
         <azure.mgmt.intune.models.LocationPaged>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations'

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def get_location_by_host_name(
            self, custom_headers=None, raw=False, **operation_config):
        """Returns location for given tenant.

        :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>`.
        :rtype: :class:`Location <azure.mgmt.intune.models.Location>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/providers/Microsoft.Intune/locations/hostName'

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.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, **operation_config)

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

        deserialized = None

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

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

        return deserialized

    def get_apps(
            self, host_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config):
        """Returns Intune Manageable apps.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param filter: The filter to apply on the operation.
        :type filter: str
        :param top:
        :type top: int
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`ApplicationPaged
         <azure.mgmt.intune.models.ApplicationPaged>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations/{hostName}/apps'
                path_format_arguments = {
                    'hostName': self._serialize.url("host_name", host_name, 'str')
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
                if filter is not None:
                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                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')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def get_mam_user_devices(
            self, host_name, user_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config):
        """Get devices for a user.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param user_name: user unique Name
        :type user_name: str
        :param filter: The filter to apply on the operation.
        :type filter: str
        :param top:
        :type top: int
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`DevicePaged <azure.mgmt.intune.models.DevicePaged>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations/{hostName}/users/{userName}/devices'
                path_format_arguments = {
                    'hostName': self._serialize.url("host_name", host_name, 'str'),
                    'userName': self._serialize.url("user_name", user_name, 'str')
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
                if filter is not None:
                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                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')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def get_mam_user_device_by_device_name(
            self, host_name, user_name, device_name, select=None, custom_headers=None, raw=False, **operation_config):
        """Get a unique device for a user.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param user_name: unique user name
        :type user_name: str
        :param device_name: device name
        :type device_name: str
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`Device <azure.mgmt.intune.models.Device>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/providers/Microsoft.Intune/locations/{hostName}/users/{userName}/devices/{deviceName}'
        path_format_arguments = {
            'hostName': self._serialize.url("host_name", host_name, 'str'),
            'userName': self._serialize.url("user_name", user_name, 'str'),
            'deviceName': self._serialize.url("device_name", device_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
        if select is not None:
            query_parameters['$select'] = self._serialize.query("select", select, '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, **operation_config)

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

        deserialized = None

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

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

        return deserialized

    def wipe_mam_user_device(
            self, host_name, user_name, device_name, custom_headers=None, raw=False, **operation_config):
        """Wipe a device for a user.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param user_name: unique user name
        :type user_name: str
        :param device_name: device name
        :type device_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>`.
        :rtype: :class:`WipeDeviceOperationResult
         <azure.mgmt.intune.models.WipeDeviceOperationResult>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/providers/Microsoft.Intune/locations/{hostName}/users/{userName}/devices/{deviceName}/wipe'
        path_format_arguments = {
            'hostName': self._serialize.url("host_name", host_name, 'str'),
            'userName': self._serialize.url("user_name", user_name, 'str'),
            'deviceName': self._serialize.url("device_name", device_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.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.post(url, query_parameters)
        response = self._client.send(request, header_parameters, **operation_config)

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

        deserialized = None

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

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

        return deserialized

    def get_operation_results(
            self, host_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config):
        """Returns operationResults.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param filter: The filter to apply on the operation.
        :type filter: str
        :param top:
        :type top: int
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`OperationResultPaged
         <azure.mgmt.intune.models.OperationResultPaged>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations/{hostName}/operationResults'
                path_format_arguments = {
                    'hostName': self._serialize.url("host_name", host_name, 'str')
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
                if filter is not None:
                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                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')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def get_mam_statuses(
            self, host_name, custom_headers=None, raw=False, **operation_config):
        """Returns Intune Tenant level statuses.

        :param host_name: Location hostName for the tenant
        :type host_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>`.
        :rtype: :class:`StatusesDefault
         <azure.mgmt.intune.models.StatusesDefault>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations/{hostName}/statuses/default'
                path_format_arguments = {
                    'hostName': self._serialize.url("host_name", host_name, 'str')
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def get_mam_flagged_users(
            self, host_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config):
        """Returns Intune flagged user collection.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param filter: The filter to apply on the operation.
        :type filter: str
        :param top:
        :type top: int
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`FlaggedUserPaged
         <azure.mgmt.intune.models.FlaggedUserPaged>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers'
                path_format_arguments = {
                    'hostName': self._serialize.url("host_name", host_name, 'str')
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
                if filter is not None:
                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                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')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def get_mam_flagged_user_by_name(
            self, host_name, user_name, select=None, custom_headers=None, raw=False, **operation_config):
        """Returns Intune flagged user details.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param user_name: Flagged userName
        :type user_name: str
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`FlaggedUser <azure.mgmt.intune.models.FlaggedUser>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers/{userName}'
        path_format_arguments = {
            'hostName': self._serialize.url("host_name", host_name, 'str'),
            'userName': self._serialize.url("user_name", user_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
        if select is not None:
            query_parameters['$select'] = self._serialize.query("select", select, '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, **operation_config)

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

        deserialized = None

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

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

        return deserialized

    def get_mam_user_flagged_enrolled_apps(
            self, host_name, user_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config):
        """Returns Intune flagged enrolled app collection for the User.

        :param host_name: Location hostName for the tenant
        :type host_name: str
        :param user_name: User name for the tenant
        :type user_name: str
        :param filter: The filter to apply on the operation.
        :type filter: str
        :param top:
        :type top: int
        :param select: select specific fields in entity.
        :type select: 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>`.
        :rtype: :class:`FlaggedEnrolledAppPaged
         <azure.mgmt.intune.models.FlaggedEnrolledAppPaged>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers/{userName}/flaggedEnrolledApps'
                path_format_arguments = {
                    'hostName': self._serialize.url("host_name", host_name, 'str'),
                    'userName': self._serialize.url("user_name", user_name, 'str')
                }
                url = self._client.format_url(url, **path_format_arguments)

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
                if filter is not None:
                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                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')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized
コード例 #13
0
class PowerBIEmbeddedManagementClient(SDKClient):
    """Client to manage your Power BI Embedded workspace collections and retrieve workspaces.

    :ivar config: Configuration for client.
    :vartype config: PowerBIEmbeddedManagementClientConfiguration

    :ivar workspace_collections: WorkspaceCollections operations
    :vartype workspace_collections: azure.mgmt.powerbiembedded.operations.WorkspaceCollectionsOperations
    :ivar workspaces: Workspaces operations
    :vartype workspaces: azure.mgmt.powerbiembedded.operations.WorkspacesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Gets subscription credentials which uniquely
     identify a Microsoft Azure subscription. The subscription ID forms part of
     the URI for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = PowerBIEmbeddedManagementClientConfiguration(credentials, subscription_id, base_url)
        super(PowerBIEmbeddedManagementClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2016-01-29'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.workspace_collections = WorkspaceCollectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workspaces = WorkspacesOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def get_available_operations(
            self, custom_headers=None, raw=False, **operation_config):
        """Indicates which operations can be performed by the Power BI Resource
        Provider.

        :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: OperationList or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.powerbiembedded.models.OperationList or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorException<azure.mgmt.powerbiembedded.models.ErrorException>`
        """
        # Construct URL
        url = self.get_available_operations.metadata['url']

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

        deserialized = None

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

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

        return deserialized
    get_available_operations.metadata = {'url': '/providers/Microsoft.PowerBI/operations'}
コード例 #14
0
class TextAnalyticsClient(SDKClient):
    """The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. No training data is needed to use this API; just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview

    :ivar config: Configuration for client.
    :vartype config: TextAnalyticsClientConfiguration

    :param endpoint: Supported Cognitive Services endpoints (protocol and
     hostname, for example: https://westus.api.cognitive.microsoft.com).
    :type endpoint: str
    :param credentials: Subscription credentials which uniquely identify
     client subscription.
    :type credentials: None
    """
    def __init__(self, endpoint, credentials):

        self.config = TextAnalyticsClientConfiguration(endpoint, credentials)
        super(TextAnalyticsClient, self).__init__(self.config.credentials,
                                                  self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self.api_version = 'v2.1'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    def detect_language(self,
                        show_stats=None,
                        documents=None,
                        custom_headers=None,
                        raw=False,
                        **operation_config):
        """The API returns the detected language and a numeric score between 0 and
        1.

        Scores close to 1 indicate 100% certainty that the identified language
        is true. A total of 120 languages are supported.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.LanguageInput]
        :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: LanguageBatchResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.textanalytics.models.LanguageBatchResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>`
        """
        language_batch_input = None
        if documents is not None:
            language_batch_input = models.LanguageBatchInput(
                documents=documents)

        # Construct URL
        url = self.detect_language.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query(
                "show_stats", show_stats, 'bool')

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

        # Construct body
        if language_batch_input is not None:
            body_content = self._serialize.body(language_batch_input,
                                                'LanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

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

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

        return deserialized

    detect_language.metadata = {'url': '/languages'}

    def entities(self,
                 show_stats=None,
                 documents=None,
                 custom_headers=None,
                 raw=False,
                 **operation_config):
        """The API returns a list of recognized entities in a given document.

        To get even more information on each recognized entity we recommend
        using the Bing Entity Search API by querying for the recognized
        entities names. See the <a
        href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported
        languages in Text Analytics API</a> for the list of enabled languages.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput]
        :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: EntitiesBatchResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.textanalytics.models.EntitiesBatchResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>`
        """
        multi_language_batch_input = None
        if documents is not None:
            multi_language_batch_input = models.MultiLanguageBatchInput(
                documents=documents)

        # Construct URL
        url = self.entities.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query(
                "show_stats", show_stats, 'bool')

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

        # Construct body
        if multi_language_batch_input is not None:
            body_content = self._serialize.body(multi_language_batch_input,
                                                'MultiLanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

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

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

        return deserialized

    entities.metadata = {'url': '/entities'}

    def key_phrases(self,
                    show_stats=None,
                    documents=None,
                    custom_headers=None,
                    raw=False,
                    **operation_config):
        """The API returns a list of strings denoting the key talking points in
        the input text.

        See the <a
        href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text
        Analytics Documentation</a> for details about the languages that are
        supported by key phrase extraction.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput]
        :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: KeyPhraseBatchResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.textanalytics.models.KeyPhraseBatchResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>`
        """
        multi_language_batch_input = None
        if documents is not None:
            multi_language_batch_input = models.MultiLanguageBatchInput(
                documents=documents)

        # Construct URL
        url = self.key_phrases.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query(
                "show_stats", show_stats, 'bool')

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

        # Construct body
        if multi_language_batch_input is not None:
            body_content = self._serialize.body(multi_language_batch_input,
                                                'MultiLanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

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

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

        return deserialized

    key_phrases.metadata = {'url': '/keyPhrases'}

    def sentiment(self,
                  show_stats=None,
                  documents=None,
                  custom_headers=None,
                  raw=False,
                  **operation_config):
        """The API returns a numeric score between 0 and 1.

        Scores close to 1 indicate positive sentiment, while scores close to 0
        indicate negative sentiment. A score of 0.5 indicates the lack of
        sentiment (e.g. a factoid statement). See the <a
        href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text
        Analytics Documentation</a> for details about the languages that are
        supported by sentiment analysis.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput]
        :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: object or ClientRawResponse if raw=true
        :rtype: object or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        multi_language_batch_input = None
        if documents is not None:
            multi_language_batch_input = models.MultiLanguageBatchInput(
                documents=documents)

        # Construct URL
        url = self.sentiment.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query(
                "show_stats", show_stats, 'bool')

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

        # Construct body
        if multi_language_batch_input is not None:
            body_content = self._serialize.body(multi_language_batch_input,
                                                'MultiLanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('SentimentBatchResult', response)
        if response.status_code == 500:
            deserialized = self._deserialize('ErrorResponse', response)

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

        return deserialized

    sentiment.metadata = {'url': '/sentiment'}
class MemberEntitlementManagementClient(Client):
    """MemberEntitlementManagement
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(MemberEntitlementManagementClient,
              self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '68ddce18-2501-45f1-a17b-7931a9922690'

    def add_group_entitlement(self, group_entitlement, rule_option=None):
        """AddGroupEntitlement.
        [Preview API] Create a group entitlement with license rule, extension rule.
        :param :class:`<GroupEntitlement> <azure.devops.v6_0.member_entitlement_management.models.GroupEntitlement>` group_entitlement: GroupEntitlement object specifying License Rule, Extensions Rule for the group. Based on the rules the members of the group will be given licenses and extensions. The Group Entitlement can be used to add the group to another project level groups
        :param str rule_option: RuleOption [ApplyGroupRule/TestApplyGroupRule] - specifies if the rules defined in group entitlement should be created and applied to it’s members (default option) or just be tested
        :rtype: :class:`<GroupEntitlementOperationReference> <azure.devops.v6_0.member_entitlement_management.models.GroupEntitlementOperationReference>`
        """
        query_parameters = {}
        if rule_option is not None:
            query_parameters['ruleOption'] = self._serialize.query(
                'rule_option', rule_option, 'str')
        content = self._serialize.body(group_entitlement, 'GroupEntitlement')
        response = self._send(
            http_method='POST',
            location_id='2280bffa-58a2-49da-822e-0764a1bb44f7',
            version='6.0-preview.1',
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('GroupEntitlementOperationReference',
                                 response)

    def delete_group_entitlement(self,
                                 group_id,
                                 rule_option=None,
                                 remove_group_membership=None):
        """DeleteGroupEntitlement.
        [Preview API] Delete a group entitlement.
        :param str group_id: ID of the group to delete.
        :param str rule_option: RuleOption [ApplyGroupRule/TestApplyGroupRule] - specifies if the rules defined in group entitlement should be deleted and the changes are applied to it’s members (default option) or just be tested
        :param bool remove_group_membership: Optional parameter that specifies whether the group with the given ID should be removed from all other groups
        :rtype: :class:`<GroupEntitlementOperationReference> <azure.devops.v6_0.member_entitlement_management.models.GroupEntitlementOperationReference>`
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        query_parameters = {}
        if rule_option is not None:
            query_parameters['ruleOption'] = self._serialize.query(
                'rule_option', rule_option, 'str')
        if remove_group_membership is not None:
            query_parameters['removeGroupMembership'] = self._serialize.query(
                'remove_group_membership', remove_group_membership, 'bool')
        response = self._send(
            http_method='DELETE',
            location_id='2280bffa-58a2-49da-822e-0764a1bb44f7',
            version='6.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('GroupEntitlementOperationReference',
                                 response)

    def get_group_entitlement(self, group_id):
        """GetGroupEntitlement.
        [Preview API] Get a group entitlement.
        :param str group_id: ID of the group.
        :rtype: :class:`<GroupEntitlement> <azure.devops.v6_0.member_entitlement_management.models.GroupEntitlement>`
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='2280bffa-58a2-49da-822e-0764a1bb44f7',
            version='6.0-preview.1',
            route_values=route_values)
        return self._deserialize('GroupEntitlement', response)

    def update_group_entitlement(self, document, group_id, rule_option=None):
        """UpdateGroupEntitlement.
        [Preview API] Update entitlements (License Rule, Extensions Rule, Project memberships etc.) for a group.
        :param :class:`<[JsonPatchOperation]> <azure.devops.v6_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the group.
        :param str group_id: ID of the group.
        :param str rule_option: RuleOption [ApplyGroupRule/TestApplyGroupRule] - specifies if the rules defined in group entitlement should be updated and the changes are applied to it’s members (default option) or just be tested
        :rtype: :class:`<GroupEntitlementOperationReference> <azure.devops.v6_0.member_entitlement_management.models.GroupEntitlementOperationReference>`
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        query_parameters = {}
        if rule_option is not None:
            query_parameters['ruleOption'] = self._serialize.query(
                'rule_option', rule_option, 'str')
        content = self._serialize.body(document, '[JsonPatchOperation]')
        response = self._send(
            http_method='PATCH',
            location_id='2280bffa-58a2-49da-822e-0764a1bb44f7',
            version='6.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content,
            media_type='application/json-patch+json')
        return self._deserialize('GroupEntitlementOperationReference',
                                 response)

    def get_group_entitlements(self):
        """GetGroupEntitlements.
        [Preview API] Get the group entitlements for an account.
        :rtype: [GroupEntitlement]
        """
        response = self._send(
            http_method='GET',
            location_id='9bce1f43-2629-419f-8f6c-7503be58a4f3',
            version='6.0-preview.1')
        return self._deserialize('[GroupEntitlement]',
                                 self._unwrap_collection(response))

    def add_member_to_group(self, group_id, member_id):
        """AddMemberToGroup.
        [Preview API] Add a member to a Group.
        :param str group_id: Id of the Group.
        :param str member_id: Id of the member to add.
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        self._send(http_method='PUT',
                   location_id='45a36e53-5286-4518-aa72-2d29f7acc5d8',
                   version='6.0-preview.1',
                   route_values=route_values)

    def get_group_members(self, group_id, max_results=None, paging_token=None):
        """GetGroupMembers.
        [Preview API] Get direct members of a Group.
        :param str group_id: Id of the Group.
        :param int max_results: Maximum number of results to retrieve.
        :param str paging_token: Paging Token from the previous page fetched. If the 'pagingToken' is null, the results would be fetched from the beginning of the Members List.
        :rtype: :class:`<PagedGraphMemberList> <azure.devops.v6_0.member_entitlement_management.models.PagedGraphMemberList>`
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        query_parameters = {}
        if max_results is not None:
            query_parameters['maxResults'] = self._serialize.query(
                'max_results', max_results, 'int')
        if paging_token is not None:
            query_parameters['pagingToken'] = self._serialize.query(
                'paging_token', paging_token, 'str')
        response = self._send(
            http_method='GET',
            location_id='45a36e53-5286-4518-aa72-2d29f7acc5d8',
            version='6.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('PagedGraphMemberList', response)

    def remove_member_from_group(self, group_id, member_id):
        """RemoveMemberFromGroup.
        [Preview API] Remove a member from a Group.
        :param str group_id: Id of the group.
        :param str member_id: Id of the member to remove.
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        self._send(http_method='DELETE',
                   location_id='45a36e53-5286-4518-aa72-2d29f7acc5d8',
                   version='6.0-preview.1',
                   route_values=route_values)

    def add_user_entitlement(self, user_entitlement):
        """AddUserEntitlement.
        [Preview API] Add a user, assign license and extensions and make them a member of a project group in an account.
        :param :class:`<UserEntitlement> <azure.devops.v6_0.member_entitlement_management.models.UserEntitlement>` user_entitlement: UserEntitlement object specifying License, Extensions and Project/Team groups the user should be added to.
        :rtype: :class:`<UserEntitlementsPostResponse> <azure.devops.v6_0.member_entitlement_management.models.UserEntitlementsPostResponse>`
        """
        content = self._serialize.body(user_entitlement, 'UserEntitlement')
        response = self._send(
            http_method='POST',
            location_id='387f832c-dbf2-4643-88e9-c1aa94dbb737',
            version='6.0-preview.3',
            content=content)
        return self._deserialize('UserEntitlementsPostResponse', response)

    def search_user_entitlements(self,
                                 continuation_token=None,
                                 select=None,
                                 filter=None,
                                 order_by=None):
        """SearchUserEntitlements.
        [Preview API] Get a paged set of user entitlements matching the filter and sort criteria built with properties that match the select input.
        :param str continuation_token: Continuation token for getting the next page of data set. If null is passed, gets the first page.
        :param str select: Comma (",") separated list of properties to select in the result entitlements. names of the properties are - 'Projects, 'Extensions' and 'Grouprules'.
        :param str filter: Equality operators relating to searching user entitlements seperated by and clauses. Valid filters include: licenseId, licenseStatus, userType, and name. licenseId: filters based on license assignment using license names. i.e. licenseId eq 'Account-Stakeholder' or licenseId eq 'Account-Express'. licenseStatus: filters based on license status. currently only supports disabled. i.e. licenseStatus eq 'Disabled'. To get disabled basic licenses, you would pass (licenseId eq 'Account-Express' and licenseStatus eq 'Disabled') userType: filters off identity type. Suppored types are member or guest i.e. userType eq 'member'. name: filters on if the user's display name or email contians given input. i.e. get all users with "test" in email or displayname is "name eq 'test'". A valid query could be: (licenseId eq 'Account-Stakeholder' or (licenseId eq 'Account-Express' and licenseStatus eq 'Disabled')) and name eq 'test' and userType eq 'guest'.
        :param str order_by: PropertyName and Order (separated by a space ( )) to sort on (e.g. lastAccessed desc). Order defaults to ascending. valid properties to order by are dateCreated, lastAccessed, and name
        :rtype: :class:`<PagedGraphMemberList> <azure.devops.v6_0.member_entitlement_management.models.PagedGraphMemberList>`
        """
        query_parameters = {}
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'str')
        if select is not None:
            query_parameters['select'] = self._serialize.query(
                'select', select, 'str')
        if filter is not None:
            query_parameters['$filter'] = self._serialize.query(
                'filter', filter, 'str')
        if order_by is not None:
            query_parameters['$orderBy'] = self._serialize.query(
                'order_by', order_by, 'str')
        response = self._send(
            http_method='GET',
            location_id='387f832c-dbf2-4643-88e9-c1aa94dbb737',
            version='6.0-preview.3',
            query_parameters=query_parameters)
        return self._deserialize('PagedGraphMemberList', response)

    def update_user_entitlements(self,
                                 document,
                                 do_not_send_invite_for_new_users=None):
        """UpdateUserEntitlements.
        [Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for one or more users.
        :param :class:`<[JsonPatchOperation]> <azure.devops.v6_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform.
        :param bool do_not_send_invite_for_new_users: Whether to send email invites to new users or not
        :rtype: :class:`<UserEntitlementOperationReference> <azure.devops.v6_0.member_entitlement_management.models.UserEntitlementOperationReference>`
        """
        query_parameters = {}
        if do_not_send_invite_for_new_users is not None:
            query_parameters[
                'doNotSendInviteForNewUsers'] = self._serialize.query(
                    'do_not_send_invite_for_new_users',
                    do_not_send_invite_for_new_users, 'bool')
        content = self._serialize.body(document, '[JsonPatchOperation]')
        response = self._send(
            http_method='PATCH',
            location_id='387f832c-dbf2-4643-88e9-c1aa94dbb737',
            version='6.0-preview.3',
            query_parameters=query_parameters,
            content=content,
            media_type='application/json-patch+json')
        return self._deserialize('UserEntitlementOperationReference', response)

    def delete_user_entitlement(self, user_id):
        """DeleteUserEntitlement.
        [Preview API] Delete a user from the account.
        :param str user_id: ID of the user.
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        self._send(http_method='DELETE',
                   location_id='8480c6eb-ce60-47e9-88df-eca3c801638b',
                   version='6.0-preview.3',
                   route_values=route_values)

    def get_user_entitlement(self, user_id):
        """GetUserEntitlement.
        [Preview API] Get User Entitlement for a user.
        :param str user_id: ID of the user.
        :rtype: :class:`<UserEntitlement> <azure.devops.v6_0.member_entitlement_management.models.UserEntitlement>`
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='8480c6eb-ce60-47e9-88df-eca3c801638b',
            version='6.0-preview.3',
            route_values=route_values)
        return self._deserialize('UserEntitlement', response)

    def update_user_entitlement(self, document, user_id):
        """UpdateUserEntitlement.
        [Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user.
        :param :class:`<[JsonPatchOperation]> <azure.devops.v6_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the user.
        :param str user_id: ID of the user.
        :rtype: :class:`<UserEntitlementsPatchResponse> <azure.devops.v6_0.member_entitlement_management.models.UserEntitlementsPatchResponse>`
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        content = self._serialize.body(document, '[JsonPatchOperation]')
        response = self._send(
            http_method='PATCH',
            location_id='8480c6eb-ce60-47e9-88df-eca3c801638b',
            version='6.0-preview.3',
            route_values=route_values,
            content=content,
            media_type='application/json-patch+json')
        return self._deserialize('UserEntitlementsPatchResponse', response)

    def get_users_summary(self, select=None):
        """GetUsersSummary.
        [Preview API] Get summary of Licenses, Extension, Projects, Groups and their assignments in the collection.
        :param str select: Comma (",") separated list of properties to select. Supported property names are {AccessLevels, Licenses, Projects, Groups}.
        :rtype: :class:`<UsersSummary> <azure.devops.v6_0.member_entitlement_management.models.UsersSummary>`
        """
        query_parameters = {}
        if select is not None:
            query_parameters['select'] = self._serialize.query(
                'select', select, 'str')
        response = self._send(
            http_method='GET',
            location_id='5ae55b13-c9dd-49d1-957e-6e76c152e3d9',
            version='6.0-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('UsersSummary', response)
コード例 #16
0
class NotificationClient(Client):
    """Notification
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(NotificationClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def list_logs(self, source, entry_id=None, start_time=None, end_time=None):
        """ListLogs.
        Get a list of diagnostic logs for this service.
        :param str source: ID specifying which type of logs to check diagnostics for.
        :param str entry_id: The ID of the specific log to query for.
        :param datetime start_time: Start time for the time range to query in.
        :param datetime end_time: End time for the time range to query in.
        :rtype: [INotificationDiagnosticLog]
        """
        route_values = {}
        if source is not None:
            route_values['source'] = self._serialize.url(
                'source', source, 'str')
        if entry_id is not None:
            route_values['entryId'] = self._serialize.url(
                'entry_id', entry_id, 'str')
        query_parameters = {}
        if start_time is not None:
            query_parameters['startTime'] = self._serialize.query(
                'start_time', start_time, 'iso-8601')
        if end_time is not None:
            query_parameters['endTime'] = self._serialize.query(
                'end_time', end_time, 'iso-8601')
        response = self._send(
            http_method='GET',
            location_id='991842f3-eb16-4aea-ac81-81353ef2b75c',
            version='5.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[INotificationDiagnosticLog]',
                                 self._unwrap_collection(response))

    def get_subscription_diagnostics(self, subscription_id):
        """GetSubscriptionDiagnostics.
        Get the diagnostics settings for a subscription.
        :param str subscription_id: The id of the notifications subscription.
        :rtype: :class:`<SubscriptionDiagnostics> <azure.devops.v5_1.notification.models.SubscriptionDiagnostics>`
        """
        route_values = {}
        if subscription_id is not None:
            route_values['subscriptionId'] = self._serialize.url(
                'subscription_id', subscription_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='20f1929d-4be7-4c2e-a74e-d47640ff3418',
            version='5.1',
            route_values=route_values)
        return self._deserialize('SubscriptionDiagnostics', response)

    def update_subscription_diagnostics(self, update_parameters,
                                        subscription_id):
        """UpdateSubscriptionDiagnostics.
        Update the diagnostics settings for a subscription.
        :param :class:`<UpdateSubscripitonDiagnosticsParameters> <azure.devops.v5_1.notification.models.UpdateSubscripitonDiagnosticsParameters>` update_parameters:
        :param str subscription_id: The id of the notifications subscription.
        :rtype: :class:`<SubscriptionDiagnostics> <azure.devops.v5_1.notification.models.SubscriptionDiagnostics>`
        """
        route_values = {}
        if subscription_id is not None:
            route_values['subscriptionId'] = self._serialize.url(
                'subscription_id', subscription_id, 'str')
        content = self._serialize.body(
            update_parameters, 'UpdateSubscripitonDiagnosticsParameters')
        response = self._send(
            http_method='PUT',
            location_id='20f1929d-4be7-4c2e-a74e-d47640ff3418',
            version='5.1',
            route_values=route_values,
            content=content)
        return self._deserialize('SubscriptionDiagnostics', response)

    def get_event_type(self, event_type):
        """GetEventType.
        Get a specific event type.
        :param str event_type: The ID of the event type.
        :rtype: :class:`<NotificationEventType> <azure.devops.v5_1.notification.models.NotificationEventType>`
        """
        route_values = {}
        if event_type is not None:
            route_values['eventType'] = self._serialize.url(
                'event_type', event_type, 'str')
        response = self._send(
            http_method='GET',
            location_id='cc84fb5f-6247-4c7a-aeae-e5a3c3fddb21',
            version='5.1',
            route_values=route_values)
        return self._deserialize('NotificationEventType', response)

    def list_event_types(self, publisher_id=None):
        """ListEventTypes.
        List available event types for this service. Optionally filter by only event types for the specified publisher.
        :param str publisher_id: Limit to event types for this publisher
        :rtype: [NotificationEventType]
        """
        query_parameters = {}
        if publisher_id is not None:
            query_parameters['publisherId'] = self._serialize.query(
                'publisher_id', publisher_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='cc84fb5f-6247-4c7a-aeae-e5a3c3fddb21',
            version='5.1',
            query_parameters=query_parameters)
        return self._deserialize('[NotificationEventType]',
                                 self._unwrap_collection(response))

    def get_settings(self):
        """GetSettings.
        :rtype: :class:`<NotificationAdminSettings> <azure.devops.v5_1.notification.models.NotificationAdminSettings>`
        """
        response = self._send(
            http_method='GET',
            location_id='cbe076d8-2803-45ff-8d8d-44653686ea2a',
            version='5.1')
        return self._deserialize('NotificationAdminSettings', response)

    def update_settings(self, update_parameters):
        """UpdateSettings.
        :param :class:`<NotificationAdminSettingsUpdateParameters> <azure.devops.v5_1.notification.models.NotificationAdminSettingsUpdateParameters>` update_parameters:
        :rtype: :class:`<NotificationAdminSettings> <azure.devops.v5_1.notification.models.NotificationAdminSettings>`
        """
        content = self._serialize.body(
            update_parameters, 'NotificationAdminSettingsUpdateParameters')
        response = self._send(
            http_method='PATCH',
            location_id='cbe076d8-2803-45ff-8d8d-44653686ea2a',
            version='5.1',
            content=content)
        return self._deserialize('NotificationAdminSettings', response)

    def get_subscriber(self, subscriber_id):
        """GetSubscriber.
        Get delivery preferences of a notifications subscriber.
        :param str subscriber_id: ID of the user or group.
        :rtype: :class:`<NotificationSubscriber> <azure.devops.v5_1.notification.models.NotificationSubscriber>`
        """
        route_values = {}
        if subscriber_id is not None:
            route_values['subscriberId'] = self._serialize.url(
                'subscriber_id', subscriber_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='4d5caff1-25ba-430b-b808-7a1f352cc197',
            version='5.1',
            route_values=route_values)
        return self._deserialize('NotificationSubscriber', response)

    def update_subscriber(self, update_parameters, subscriber_id):
        """UpdateSubscriber.
        Update delivery preferences of a notifications subscriber.
        :param :class:`<NotificationSubscriberUpdateParameters> <azure.devops.v5_1.notification.models.NotificationSubscriberUpdateParameters>` update_parameters:
        :param str subscriber_id: ID of the user or group.
        :rtype: :class:`<NotificationSubscriber> <azure.devops.v5_1.notification.models.NotificationSubscriber>`
        """
        route_values = {}
        if subscriber_id is not None:
            route_values['subscriberId'] = self._serialize.url(
                'subscriber_id', subscriber_id, 'str')
        content = self._serialize.body(
            update_parameters, 'NotificationSubscriberUpdateParameters')
        response = self._send(
            http_method='PATCH',
            location_id='4d5caff1-25ba-430b-b808-7a1f352cc197',
            version='5.1',
            route_values=route_values,
            content=content)
        return self._deserialize('NotificationSubscriber', response)

    def query_subscriptions(self, subscription_query):
        """QuerySubscriptions.
        Query for subscriptions. A subscription is returned if it matches one or more of the specified conditions.
        :param :class:`<SubscriptionQuery> <azure.devops.v5_1.notification.models.SubscriptionQuery>` subscription_query:
        :rtype: [NotificationSubscription]
        """
        content = self._serialize.body(subscription_query, 'SubscriptionQuery')
        response = self._send(
            http_method='POST',
            location_id='6864db85-08c0-4006-8e8e-cc1bebe31675',
            version='5.1',
            content=content)
        return self._deserialize('[NotificationSubscription]',
                                 self._unwrap_collection(response))

    def create_subscription(self, create_parameters):
        """CreateSubscription.
        Create a new subscription.
        :param :class:`<NotificationSubscriptionCreateParameters> <azure.devops.v5_1.notification.models.NotificationSubscriptionCreateParameters>` create_parameters:
        :rtype: :class:`<NotificationSubscription> <azure.devops.v5_1.notification.models.NotificationSubscription>`
        """
        content = self._serialize.body(
            create_parameters, 'NotificationSubscriptionCreateParameters')
        response = self._send(
            http_method='POST',
            location_id='70f911d6-abac-488c-85b3-a206bf57e165',
            version='5.1',
            content=content)
        return self._deserialize('NotificationSubscription', response)

    def delete_subscription(self, subscription_id):
        """DeleteSubscription.
        Delete a subscription.
        :param str subscription_id:
        """
        route_values = {}
        if subscription_id is not None:
            route_values['subscriptionId'] = self._serialize.url(
                'subscription_id', subscription_id, 'str')
        self._send(http_method='DELETE',
                   location_id='70f911d6-abac-488c-85b3-a206bf57e165',
                   version='5.1',
                   route_values=route_values)

    def get_subscription(self, subscription_id, query_flags=None):
        """GetSubscription.
        Get a notification subscription by its ID.
        :param str subscription_id:
        :param str query_flags:
        :rtype: :class:`<NotificationSubscription> <azure.devops.v5_1.notification.models.NotificationSubscription>`
        """
        route_values = {}
        if subscription_id is not None:
            route_values['subscriptionId'] = self._serialize.url(
                'subscription_id', subscription_id, 'str')
        query_parameters = {}
        if query_flags is not None:
            query_parameters['queryFlags'] = self._serialize.query(
                'query_flags', query_flags, 'str')
        response = self._send(
            http_method='GET',
            location_id='70f911d6-abac-488c-85b3-a206bf57e165',
            version='5.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('NotificationSubscription', response)

    def list_subscriptions(self, target_id=None, ids=None, query_flags=None):
        """ListSubscriptions.
        Get a list of notification subscriptions, either by subscription IDs or by all subscriptions for a given user or group.
        :param str target_id: User or Group ID
        :param [str] ids: List of subscription IDs
        :param str query_flags:
        :rtype: [NotificationSubscription]
        """
        query_parameters = {}
        if target_id is not None:
            query_parameters['targetId'] = self._serialize.query(
                'target_id', target_id, 'str')
        if ids is not None:
            ids = ",".join(ids)
            query_parameters['ids'] = self._serialize.query('ids', ids, 'str')
        if query_flags is not None:
            query_parameters['queryFlags'] = self._serialize.query(
                'query_flags', query_flags, 'str')
        response = self._send(
            http_method='GET',
            location_id='70f911d6-abac-488c-85b3-a206bf57e165',
            version='5.1',
            query_parameters=query_parameters)
        return self._deserialize('[NotificationSubscription]',
                                 self._unwrap_collection(response))

    def update_subscription(self, update_parameters, subscription_id):
        """UpdateSubscription.
        Update an existing subscription. Depending on the type of subscription and permissions, the caller can update the description, filter settings, channel (delivery) settings and more.
        :param :class:`<NotificationSubscriptionUpdateParameters> <azure.devops.v5_1.notification.models.NotificationSubscriptionUpdateParameters>` update_parameters:
        :param str subscription_id:
        :rtype: :class:`<NotificationSubscription> <azure.devops.v5_1.notification.models.NotificationSubscription>`
        """
        route_values = {}
        if subscription_id is not None:
            route_values['subscriptionId'] = self._serialize.url(
                'subscription_id', subscription_id, 'str')
        content = self._serialize.body(
            update_parameters, 'NotificationSubscriptionUpdateParameters')
        response = self._send(
            http_method='PATCH',
            location_id='70f911d6-abac-488c-85b3-a206bf57e165',
            version='5.1',
            route_values=route_values,
            content=content)
        return self._deserialize('NotificationSubscription', response)

    def get_subscription_templates(self):
        """GetSubscriptionTemplates.
        Get available subscription templates.
        :rtype: [NotificationSubscriptionTemplate]
        """
        response = self._send(
            http_method='GET',
            location_id='fa5d24ba-7484-4f3d-888d-4ec6b1974082',
            version='5.1')
        return self._deserialize('[NotificationSubscriptionTemplate]',
                                 self._unwrap_collection(response))

    def update_subscription_user_settings(self, user_settings, subscription_id,
                                          user_id):
        """UpdateSubscriptionUserSettings.
        Update the specified user's settings for the specified subscription. This API is typically used to opt in or out of a shared subscription. User settings can only be applied to shared subscriptions, like team subscriptions or default subscriptions.
        :param :class:`<SubscriptionUserSettings> <azure.devops.v5_1.notification.models.SubscriptionUserSettings>` user_settings:
        :param str subscription_id:
        :param str user_id: ID of the user
        :rtype: :class:`<SubscriptionUserSettings> <azure.devops.v5_1.notification.models.SubscriptionUserSettings>`
        """
        route_values = {}
        if subscription_id is not None:
            route_values['subscriptionId'] = self._serialize.url(
                'subscription_id', subscription_id, 'str')
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        content = self._serialize.body(user_settings,
                                       'SubscriptionUserSettings')
        response = self._send(
            http_method='PUT',
            location_id='ed5a3dff-aeb5-41b1-b4f7-89e66e58b62e',
            version='5.1',
            route_values=route_values,
            content=content)
        return self._deserialize('SubscriptionUserSettings', response)
コード例 #17
0
class GraphClient(VssClient):
    """Graph
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(GraphClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = 'bb1e7ec9-e901-4b68-999a-de7012b920f8'

    def get_descriptor(self, storage_key):
        """GetDescriptor.
        [Preview API] Resolve a storage key to a descriptor
        :param str storage_key: Storage key of the subject (user, group, scope, etc.) to resolve
        :rtype: :class:`<GraphDescriptorResult> <graph.v4_1.models.GraphDescriptorResult>`
        """
        route_values = {}
        if storage_key is not None:
            route_values['storageKey'] = self._serialize.url(
                'storage_key', storage_key, 'str')
        response = self._send(
            http_method='GET',
            location_id='048aee0a-7072-4cde-ab73-7af77b1e0b4e',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphDescriptorResult', response)

    def create_group(self,
                     creation_context,
                     scope_descriptor=None,
                     group_descriptors=None):
        """CreateGroup.
        [Preview API] Create a new VSTS group or materialize an existing AAD group.
        :param :class:`<GraphGroupCreationContext> <graph.v4_1.models.GraphGroupCreationContext>` creation_context: The subset of the full graph group used to uniquely find the graph subject in an external provider.
        :param str scope_descriptor: A descriptor referencing the scope (collection, project) in which the group should be created. If omitted, will be created in the scope of the enclosing account or organization. Valid only for VSTS groups.
        :param [str] group_descriptors: A comma separated list of descriptors referencing groups you want the graph group to join
        :rtype: :class:`<GraphGroup> <graph.v4_1.models.GraphGroup>`
        """
        query_parameters = {}
        if scope_descriptor is not None:
            query_parameters['scopeDescriptor'] = self._serialize.query(
                'scope_descriptor', scope_descriptor, 'str')
        if group_descriptors is not None:
            group_descriptors = ",".join(group_descriptors)
            query_parameters['groupDescriptors'] = self._serialize.query(
                'group_descriptors', group_descriptors, 'str')
        content = self._serialize.body(creation_context,
                                       'GraphGroupCreationContext')
        response = self._send(
            http_method='POST',
            location_id='ebbe6af8-0b91-4c13-8cf1-777c14858188',
            version='4.1-preview.1',
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('GraphGroup', response)

    def delete_group(self, group_descriptor):
        """DeleteGroup.
        [Preview API] Removes a VSTS group from all of its parent groups.
        :param str group_descriptor: The descriptor of the group to delete.
        """
        route_values = {}
        if group_descriptor is not None:
            route_values['groupDescriptor'] = self._serialize.url(
                'group_descriptor', group_descriptor, 'str')
        self._send(http_method='DELETE',
                   location_id='ebbe6af8-0b91-4c13-8cf1-777c14858188',
                   version='4.1-preview.1',
                   route_values=route_values)

    def get_group(self, group_descriptor):
        """GetGroup.
        [Preview API] Get a group by its descriptor.
        :param str group_descriptor: The descriptor of the desired graph group.
        :rtype: :class:`<GraphGroup> <graph.v4_1.models.GraphGroup>`
        """
        route_values = {}
        if group_descriptor is not None:
            route_values['groupDescriptor'] = self._serialize.url(
                'group_descriptor', group_descriptor, 'str')
        response = self._send(
            http_method='GET',
            location_id='ebbe6af8-0b91-4c13-8cf1-777c14858188',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphGroup', response)

    def update_group(self, group_descriptor, patch_document):
        """UpdateGroup.
        [Preview API] Update the properties of a VSTS group.
        :param str group_descriptor: The descriptor of the group to modify.
        :param :class:`<[JsonPatchOperation]> <graph.v4_1.models.[JsonPatchOperation]>` patch_document: The JSON+Patch document containing the fields to alter.
        :rtype: :class:`<GraphGroup> <graph.v4_1.models.GraphGroup>`
        """
        route_values = {}
        if group_descriptor is not None:
            route_values['groupDescriptor'] = self._serialize.url(
                'group_descriptor', group_descriptor, 'str')
        content = self._serialize.body(patch_document, '[JsonPatchOperation]')
        response = self._send(
            http_method='PATCH',
            location_id='ebbe6af8-0b91-4c13-8cf1-777c14858188',
            version='4.1-preview.1',
            route_values=route_values,
            content=content,
            media_type='application/json-patch+json')
        return self._deserialize('GraphGroup', response)

    def add_membership(self, subject_descriptor, container_descriptor):
        """AddMembership.
        [Preview API] Create a new membership between a container and subject.
        :param str subject_descriptor: A descriptor to a group or user that can be the child subject in the relationship.
        :param str container_descriptor: A descriptor to a group that can be the container in the relationship.
        :rtype: :class:`<GraphMembership> <graph.v4_1.models.GraphMembership>`
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        if container_descriptor is not None:
            route_values['containerDescriptor'] = self._serialize.url(
                'container_descriptor', container_descriptor, 'str')
        response = self._send(
            http_method='PUT',
            location_id='3fd2e6ca-fb30-443a-b579-95b19ed0934c',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphMembership', response)

    def check_membership_existence(self, subject_descriptor,
                                   container_descriptor):
        """CheckMembershipExistence.
        [Preview API] Check to see if a membership relationship between a container and subject exists.
        :param str subject_descriptor: The group or user that is a child subject of the relationship.
        :param str container_descriptor: The group that is the container in the relationship.
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        if container_descriptor is not None:
            route_values['containerDescriptor'] = self._serialize.url(
                'container_descriptor', container_descriptor, 'str')
        self._send(http_method='HEAD',
                   location_id='3fd2e6ca-fb30-443a-b579-95b19ed0934c',
                   version='4.1-preview.1',
                   route_values=route_values)

    def get_membership(self, subject_descriptor, container_descriptor):
        """GetMembership.
        [Preview API] Get a membership relationship between a container and subject.
        :param str subject_descriptor: A descriptor to the child subject in the relationship.
        :param str container_descriptor: A descriptor to the container in the relationship.
        :rtype: :class:`<GraphMembership> <graph.v4_1.models.GraphMembership>`
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        if container_descriptor is not None:
            route_values['containerDescriptor'] = self._serialize.url(
                'container_descriptor', container_descriptor, 'str')
        response = self._send(
            http_method='GET',
            location_id='3fd2e6ca-fb30-443a-b579-95b19ed0934c',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphMembership', response)

    def remove_membership(self, subject_descriptor, container_descriptor):
        """RemoveMembership.
        [Preview API] Deletes a membership between a container and subject.
        :param str subject_descriptor: A descriptor to a group or user that is the child subject in the relationship.
        :param str container_descriptor: A descriptor to a group that is the container in the relationship.
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        if container_descriptor is not None:
            route_values['containerDescriptor'] = self._serialize.url(
                'container_descriptor', container_descriptor, 'str')
        self._send(http_method='DELETE',
                   location_id='3fd2e6ca-fb30-443a-b579-95b19ed0934c',
                   version='4.1-preview.1',
                   route_values=route_values)

    def list_memberships(self, subject_descriptor, direction=None, depth=None):
        """ListMemberships.
        [Preview API] Get all the memberships where this descriptor is a member in the relationship.
        :param str subject_descriptor: Fetch all direct memberships of this descriptor.
        :param str direction: Defaults to Up.
        :param int depth: The maximum number of edges to traverse up or down the membership tree. Currently the only supported value is '1'.
        :rtype: [GraphMembership]
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        query_parameters = {}
        if direction is not None:
            query_parameters['direction'] = self._serialize.query(
                'direction', direction, 'str')
        if depth is not None:
            query_parameters['depth'] = self._serialize.query(
                'depth', depth, 'int')
        response = self._send(
            http_method='GET',
            location_id='e34b6394-6b30-4435-94a9-409a5eef3e31',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[GraphMembership]', response)

    def get_membership_state(self, subject_descriptor):
        """GetMembershipState.
        [Preview API] Check whether a subject is active or inactive.
        :param str subject_descriptor: Descriptor of the subject (user, group, scope, etc.) to check state of
        :rtype: :class:`<GraphMembershipState> <graph.v4_1.models.GraphMembershipState>`
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        response = self._send(
            http_method='GET',
            location_id='1ffe5c94-1144-4191-907b-d0211cad36a8',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphMembershipState', response)

    def get_storage_key(self, subject_descriptor):
        """GetStorageKey.
        [Preview API] Resolve a descriptor to a storage key.
        :param str subject_descriptor:
        :rtype: :class:`<GraphStorageKeyResult> <graph.v4_1.models.GraphStorageKeyResult>`
        """
        route_values = {}
        if subject_descriptor is not None:
            route_values['subjectDescriptor'] = self._serialize.url(
                'subject_descriptor', subject_descriptor, 'str')
        response = self._send(
            http_method='GET',
            location_id='eb85f8cc-f0f6-4264-a5b1-ffe2e4d4801f',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphStorageKeyResult', response)

    def lookup_subjects(self, subject_lookup):
        """LookupSubjects.
        [Preview API] Resolve descriptors to users, groups or scopes (Subjects) in a batch.
        :param :class:`<GraphSubjectLookup> <graph.v4_1.models.GraphSubjectLookup>` subject_lookup: A list of descriptors that specifies a subset of subjects to retrieve. Each descriptor uniquely identifies the subject across all instance scopes, but only at a single point in time.
        :rtype: {GraphSubject}
        """
        content = self._serialize.body(subject_lookup, 'GraphSubjectLookup')
        response = self._send(
            http_method='POST',
            location_id='4dd4d168-11f2-48c4-83e8-756fa0de027c',
            version='4.1-preview.1',
            content=content,
            returns_collection=True)
        return self._deserialize('{GraphSubject}', response)

    def create_user(self, creation_context, group_descriptors=None):
        """CreateUser.
        [Preview API] Materialize an existing AAD or MSA user into the VSTS account.
        :param :class:`<GraphUserCreationContext> <graph.v4_1.models.GraphUserCreationContext>` creation_context: The subset of the full graph user used to uniquely find the graph subject in an external provider.
        :param [str] group_descriptors: A comma separated list of descriptors of groups you want the graph user to join
        :rtype: :class:`<GraphUser> <graph.v4_1.models.GraphUser>`
        """
        query_parameters = {}
        if group_descriptors is not None:
            group_descriptors = ",".join(group_descriptors)
            query_parameters['groupDescriptors'] = self._serialize.query(
                'group_descriptors', group_descriptors, 'str')
        content = self._serialize.body(creation_context,
                                       'GraphUserCreationContext')
        response = self._send(
            http_method='POST',
            location_id='005e26ec-6b77-4e4f-a986-b3827bf241f5',
            version='4.1-preview.1',
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('GraphUser', response)

    def delete_user(self, user_descriptor):
        """DeleteUser.
        [Preview API] Disables a user.
        :param str user_descriptor: The descriptor of the user to delete.
        """
        route_values = {}
        if user_descriptor is not None:
            route_values['userDescriptor'] = self._serialize.url(
                'user_descriptor', user_descriptor, 'str')
        self._send(http_method='DELETE',
                   location_id='005e26ec-6b77-4e4f-a986-b3827bf241f5',
                   version='4.1-preview.1',
                   route_values=route_values)

    def get_user(self, user_descriptor):
        """GetUser.
        [Preview API] Get a user by its descriptor.
        :param str user_descriptor: The descriptor of the desired user.
        :rtype: :class:`<GraphUser> <graph.v4_1.models.GraphUser>`
        """
        route_values = {}
        if user_descriptor is not None:
            route_values['userDescriptor'] = self._serialize.url(
                'user_descriptor', user_descriptor, 'str')
        response = self._send(
            http_method='GET',
            location_id='005e26ec-6b77-4e4f-a986-b3827bf241f5',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('GraphUser', response)
コード例 #18
0
class AzureReservationAPI(object):
    """This API describe Azure Reservation

    :ivar config: Configuration for client.
    :vartype config: AzureReservationAPIConfiguration

    :ivar reservation_order: ReservationOrder operations
    :vartype reservation_order: reservations.operations.ReservationOrderOperations
    :ivar reservation: Reservation operations
    :vartype reservation: reservations.operations.ReservationOperations
    :ivar operation: Operation operations
    :vartype operation: reservations.operations.OperationOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, base_url=None):

        self.config = AzureReservationAPIConfiguration(credentials, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2017-11-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.reservation_order = ReservationOrderOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.reservation = ReservationOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.operation = OperationOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def get_catalog(
            self, subscription_id, custom_headers=None, raw=False, **operation_config):
        """Get the regions and skus that are available for RI purchase for the
        specified Azure subscription.

        :param subscription_id: Id of the subscription
        :type subscription_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: list of :class:`Catalog <reservations.models.Catalog>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: list of :class:`Catalog <reservations.models.Catalog>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises: :class:`ErrorException<reservations.models.ErrorException>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs'
        path_format_arguments = {
            'subscriptionId': self._serialize.url("subscription_id", subscription_id, '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, **operation_config)

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('[Catalog]', response)

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

        return deserialized

    def get_applied_reservation_list(
            self, subscription_id, custom_headers=None, raw=False, **operation_config):
        """Get list of applicable `Reservation`s.

        Get applicable `Reservation`s that are applied to this subscription.

        :param subscription_id: Id of the subscription
        :type subscription_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: :class:`AppliedReservations
         <reservations.models.AppliedReservations>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: :class:`AppliedReservations
         <reservations.models.AppliedReservations>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises: :class:`ErrorException<reservations.models.ErrorException>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations'
        path_format_arguments = {
            'subscriptionId': self._serialize.url("subscription_id", subscription_id, '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, **operation_config)

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

        deserialized = None

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

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

        return deserialized
コード例 #19
0
class ServiceEndpointClient(Client):
    """ServiceEndpoint
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(ServiceEndpointClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '1814ab31-2f4f-4a9f-8761-f4d77dc5a5d7'

    def execute_service_endpoint_request(self, service_endpoint_request,
                                         project, endpoint_id):
        """ExecuteServiceEndpointRequest.
        [Preview API] Proxy for a GET request defined by a service endpoint.
        :param :class:`<ServiceEndpointRequest> <azure.devops.v6_0.service_endpoint.models.ServiceEndpointRequest>` service_endpoint_request: Service endpoint request.
        :param str project: Project ID or project name
        :param str endpoint_id: Id of the service endpoint.
        :rtype: :class:`<ServiceEndpointRequestResult> <azure.devops.v6_0.service_endpoint.models.ServiceEndpointRequestResult>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if endpoint_id is not None:
            query_parameters['endpointId'] = self._serialize.query(
                'endpoint_id', endpoint_id, 'str')
        content = self._serialize.body(service_endpoint_request,
                                       'ServiceEndpointRequest')
        response = self._send(
            http_method='POST',
            location_id='cc63bb57-2a5f-4a7a-b79c-c142d308657e',
            version='6.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('ServiceEndpointRequestResult', response)

    def create_service_endpoint(self, endpoint):
        """CreateServiceEndpoint.
        [Preview API]
        :param :class:`<ServiceEndpoint> <azure.devops.v6_0.service_endpoint.models.ServiceEndpoint>` endpoint:
        :rtype: :class:`<ServiceEndpoint> <azure.devops.v6_0.service_endpoint.models.ServiceEndpoint>`
        """
        content = self._serialize.body(endpoint, 'ServiceEndpoint')
        response = self._send(
            http_method='POST',
            location_id='14e48fdc-2c8b-41ce-a0c3-e26f6cc55bd0',
            version='6.0-preview.3',
            content=content)
        return self._deserialize('ServiceEndpoint', response)

    def delete_service_endpoint(self, endpoint_id, project_ids):
        """DeleteServiceEndpoint.
        [Preview API]
        :param str endpoint_id:
        :param [str] project_ids:
        """
        route_values = {}
        if endpoint_id is not None:
            route_values['endpointId'] = self._serialize.url(
                'endpoint_id', endpoint_id, 'str')
        query_parameters = {}
        if project_ids is not None:
            project_ids = ",".join(project_ids)
            query_parameters['projectIds'] = self._serialize.query(
                'project_ids', project_ids, 'str')
        self._send(http_method='DELETE',
                   location_id='14e48fdc-2c8b-41ce-a0c3-e26f6cc55bd0',
                   version='6.0-preview.3',
                   route_values=route_values,
                   query_parameters=query_parameters)

    def share_service_endpoint(self, endpoint_project_references, endpoint_id):
        """ShareServiceEndpoint.
        [Preview API]
        :param [ServiceEndpointProjectReference] endpoint_project_references:
        :param str endpoint_id:
        """
        route_values = {}
        if endpoint_id is not None:
            route_values['endpointId'] = self._serialize.url(
                'endpoint_id', endpoint_id, 'str')
        content = self._serialize.body(endpoint_project_references,
                                       '[ServiceEndpointProjectReference]')
        self._send(http_method='PATCH',
                   location_id='14e48fdc-2c8b-41ce-a0c3-e26f6cc55bd0',
                   version='6.0-preview.3',
                   route_values=route_values,
                   content=content)

    def update_service_endpoint(self, endpoint, endpoint_id, operation):
        """UpdateServiceEndpoint.
        [Preview API]
        :param :class:`<ServiceEndpoint> <azure.devops.v6_0.service_endpoint.models.ServiceEndpoint>` endpoint:
        :param str endpoint_id:
        :param str operation:
        :rtype: :class:`<ServiceEndpoint> <azure.devops.v6_0.service_endpoint.models.ServiceEndpoint>`
        """
        route_values = {}
        if endpoint_id is not None:
            route_values['endpointId'] = self._serialize.url(
                'endpoint_id', endpoint_id, 'str')
        query_parameters = {}
        if operation is not None:
            query_parameters['operation'] = self._serialize.query(
                'operation', operation, 'str')
        content = self._serialize.body(endpoint, 'ServiceEndpoint')
        response = self._send(
            http_method='PUT',
            location_id='14e48fdc-2c8b-41ce-a0c3-e26f6cc55bd0',
            version='6.0-preview.3',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('ServiceEndpoint', response)

    def get_service_endpoint_details(self, project, endpoint_id):
        """GetServiceEndpointDetails.
        [Preview API] Get the service endpoint details.
        :param str project: Project ID or project name
        :param str endpoint_id: Id of the service endpoint.
        :rtype: :class:`<ServiceEndpoint> <azure.devops.v6_0.service_endpoint.models.ServiceEndpoint>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if endpoint_id is not None:
            route_values['endpointId'] = self._serialize.url(
                'endpoint_id', endpoint_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='e85f1c62-adfc-4b74-b618-11a150fb195e',
            version='6.0-preview.3',
            route_values=route_values)
        return self._deserialize('ServiceEndpoint', response)

    def get_service_endpoints(self,
                              project,
                              type=None,
                              auth_schemes=None,
                              endpoint_ids=None,
                              owner=None,
                              include_failed=None,
                              include_details=None):
        """GetServiceEndpoints.
        [Preview API] Get the service endpoints.
        :param str project: Project ID or project name
        :param str type: Type of the service endpoints.
        :param [str] auth_schemes: Authorization schemes used for service endpoints.
        :param [str] endpoint_ids: Ids of the service endpoints.
        :param str owner: Owner for service endpoints.
        :param bool include_failed: Failed flag for service endpoints.
        :param bool include_details: Flag to include more details for service endpoints. This is for internal use only and the flag will be treated as false for all other requests
        :rtype: [ServiceEndpoint]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if type is not None:
            query_parameters['type'] = self._serialize.query(
                'type', type, 'str')
        if auth_schemes is not None:
            auth_schemes = ",".join(auth_schemes)
            query_parameters['authSchemes'] = self._serialize.query(
                'auth_schemes', auth_schemes, 'str')
        if endpoint_ids is not None:
            endpoint_ids = ",".join(endpoint_ids)
            query_parameters['endpointIds'] = self._serialize.query(
                'endpoint_ids', endpoint_ids, 'str')
        if owner is not None:
            query_parameters['owner'] = self._serialize.query(
                'owner', owner, 'str')
        if include_failed is not None:
            query_parameters['includeFailed'] = self._serialize.query(
                'include_failed', include_failed, 'bool')
        if include_details is not None:
            query_parameters['includeDetails'] = self._serialize.query(
                'include_details', include_details, 'bool')
        response = self._send(
            http_method='GET',
            location_id='e85f1c62-adfc-4b74-b618-11a150fb195e',
            version='6.0-preview.3',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[ServiceEndpoint]',
                                 self._unwrap_collection(response))

    def get_service_endpoints_by_names(self,
                                       project,
                                       endpoint_names,
                                       type=None,
                                       auth_schemes=None,
                                       owner=None,
                                       include_failed=None,
                                       include_details=None):
        """GetServiceEndpointsByNames.
        [Preview API] Get the service endpoints by name.
        :param str project: Project ID or project name
        :param [str] endpoint_names: Names of the service endpoints.
        :param str type: Type of the service endpoints.
        :param [str] auth_schemes: Authorization schemes used for service endpoints.
        :param str owner: Owner for service endpoints.
        :param bool include_failed: Failed flag for service endpoints.
        :param bool include_details: Flag to include more details for service endpoints. This is for internal use only and the flag will be treated as false for all other requests
        :rtype: [ServiceEndpoint]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if endpoint_names is not None:
            endpoint_names = ",".join(endpoint_names)
            query_parameters['endpointNames'] = self._serialize.query(
                'endpoint_names', endpoint_names, 'str')
        if type is not None:
            query_parameters['type'] = self._serialize.query(
                'type', type, 'str')
        if auth_schemes is not None:
            auth_schemes = ",".join(auth_schemes)
            query_parameters['authSchemes'] = self._serialize.query(
                'auth_schemes', auth_schemes, 'str')
        if owner is not None:
            query_parameters['owner'] = self._serialize.query(
                'owner', owner, 'str')
        if include_failed is not None:
            query_parameters['includeFailed'] = self._serialize.query(
                'include_failed', include_failed, 'bool')
        if include_details is not None:
            query_parameters['includeDetails'] = self._serialize.query(
                'include_details', include_details, 'bool')
        response = self._send(
            http_method='GET',
            location_id='e85f1c62-adfc-4b74-b618-11a150fb195e',
            version='6.0-preview.3',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[ServiceEndpoint]',
                                 self._unwrap_collection(response))

    def get_service_endpoint_execution_records(self,
                                               project,
                                               endpoint_id,
                                               top=None,
                                               continuation_token=None):
        """GetServiceEndpointExecutionRecords.
        [Preview API] Get service endpoint execution records.
        :param str project: Project ID or project name
        :param str endpoint_id: Id of the service endpoint.
        :param int top: Number of service endpoint execution records to get.
        :param long continuation_token: A continuation token, returned by a previous call to this method, that can be used to return the next set of records
        :rtype: :class:`<[ServiceEndpointExecutionRecord]> <azure.devops.v6_0.service_endpoint.models.[ServiceEndpointExecutionRecord]>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if endpoint_id is not None:
            route_values['endpointId'] = self._serialize.url(
                'endpoint_id', endpoint_id, 'str')
        query_parameters = {}
        if top is not None:
            query_parameters['top'] = self._serialize.query('top', top, 'int')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'long')
        response = self._send(
            http_method='GET',
            location_id='10a16738-9299-4cd1-9a81-fd23ad6200d0',
            version='6.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[ServiceEndpointExecutionRecord]',
                                 self._unwrap_collection(response))

    def get_service_endpoint_types(self, type=None, scheme=None):
        """GetServiceEndpointTypes.
        [Preview API] Get service endpoint types.
        :param str type: Type of service endpoint.
        :param str scheme: Scheme of service endpoint.
        :rtype: [ServiceEndpointType]
        """
        query_parameters = {}
        if type is not None:
            query_parameters['type'] = self._serialize.query(
                'type', type, 'str')
        if scheme is not None:
            query_parameters['scheme'] = self._serialize.query(
                'scheme', scheme, 'str')
        response = self._send(
            http_method='GET',
            location_id='5a7938a4-655e-486c-b562-b78c54a7e87b',
            version='6.0-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[ServiceEndpointType]',
                                 self._unwrap_collection(response))
class PowerBIEmbeddedManagementClient(object):
    """Client to manage your Power BI Embedded workspace collections and retrieve workspaces.

    :ivar config: Configuration for client.
    :vartype config: PowerBIEmbeddedManagementClientConfiguration

    :ivar workspace_collections: WorkspaceCollections operations
    :vartype workspace_collections: .operations.WorkspaceCollectionsOperations
    :ivar workspaces: Workspaces operations
    :vartype workspaces: .operations.WorkspacesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Gets subscription credentials which uniquely
     identify a Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param api_version: Client Api Version.
    :type api_version: str
    :param accept_language: Gets or sets the preferred language for the
     response.
    :type accept_language: str
    :param long_running_operation_retry_timeout: Gets or sets the retry
     timeout in seconds for Long Running Operations. Default value is 30.
    :type long_running_operation_retry_timeout: int
    :param generate_client_request_id: When set to true a unique
     x-ms-client-request-id value is generated and included in each request.
     Default is true.
    :type generate_client_request_id: bool
    :param str base_url: Service URL
    :param str filepath: Existing config
    """

    def __init__(
            self, credentials, subscription_id, api_version='2016-01-29', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):

        self.config = PowerBIEmbeddedManagementClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.workspace_collections = WorkspaceCollectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workspaces = WorkspacesOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def get_available_operations(
            self, custom_headers=None, raw=False, **operation_config):
        """Indicates which operations can be performed by the Power BI Resource
        Provider.

        :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>`.
        :rtype: :class:`OperationList
         <azure.mgmt.powerbiembedded.models.OperationList>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises:
         :class:`ErrorException<azure.mgmt.powerbiembedded.models.ErrorException>`
        """
        # Construct URL
        url = '/providers/Microsoft.PowerBI/operations'

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.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, **operation_config)

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

        deserialized = None

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

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

        return deserialized
コード例 #21
0
class TfvcClient(Client):
    """Tfvc
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(TfvcClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '8aa40520-446d-40e6-89f6-9c9f9ce44c48'

    def get_branch(self,
                   path,
                   project=None,
                   include_parent=None,
                   include_children=None):
        """GetBranch.
        [Preview API] Get a single branch hierarchy at the given path with parents or children as specified.
        :param str path: Full path to the branch.  Default: $/ Examples: $/, $/MyProject, $/MyProject/SomeFolder.
        :param str project: Project ID or project name
        :param bool include_parent: Return the parent branch, if there is one. Default: False
        :param bool include_children: Return child branches, if there are any. Default: False
        :rtype: :class:`<TfvcBranch> <azure.devops.v5_1.tfvc.models.TfvcBranch>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if path is not None:
            query_parameters['path'] = self._serialize.query(
                'path', path, 'str')
        if include_parent is not None:
            query_parameters['includeParent'] = self._serialize.query(
                'include_parent', include_parent, 'bool')
        if include_children is not None:
            query_parameters['includeChildren'] = self._serialize.query(
                'include_children', include_children, 'bool')
        response = self._send(
            http_method='GET',
            location_id='bc1f417e-239d-42e7-85e1-76e80cb2d6eb',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('TfvcBranch', response)

    def get_branches(self,
                     project=None,
                     include_parent=None,
                     include_children=None,
                     include_deleted=None,
                     include_links=None):
        """GetBranches.
        [Preview API] Get a collection of branch roots -- first-level children, branches with no parents.
        :param str project: Project ID or project name
        :param bool include_parent: Return the parent branch, if there is one. Default: False
        :param bool include_children: Return the child branches for each root branch. Default: False
        :param bool include_deleted: Return deleted branches. Default: False
        :param bool include_links: Return links. Default: False
        :rtype: [TfvcBranch]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if include_parent is not None:
            query_parameters['includeParent'] = self._serialize.query(
                'include_parent', include_parent, 'bool')
        if include_children is not None:
            query_parameters['includeChildren'] = self._serialize.query(
                'include_children', include_children, 'bool')
        if include_deleted is not None:
            query_parameters['includeDeleted'] = self._serialize.query(
                'include_deleted', include_deleted, 'bool')
        if include_links is not None:
            query_parameters['includeLinks'] = self._serialize.query(
                'include_links', include_links, 'bool')
        response = self._send(
            http_method='GET',
            location_id='bc1f417e-239d-42e7-85e1-76e80cb2d6eb',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcBranch]',
                                 self._unwrap_collection(response))

    def get_branch_refs(self,
                        scope_path,
                        project=None,
                        include_deleted=None,
                        include_links=None):
        """GetBranchRefs.
        [Preview API] Get branch hierarchies below the specified scopePath
        :param str scope_path: Full path to the branch.  Default: $/ Examples: $/, $/MyProject, $/MyProject/SomeFolder.
        :param str project: Project ID or project name
        :param bool include_deleted: Return deleted branches. Default: False
        :param bool include_links: Return links. Default: False
        :rtype: [TfvcBranchRef]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if scope_path is not None:
            query_parameters['scopePath'] = self._serialize.query(
                'scope_path', scope_path, 'str')
        if include_deleted is not None:
            query_parameters['includeDeleted'] = self._serialize.query(
                'include_deleted', include_deleted, 'bool')
        if include_links is not None:
            query_parameters['includeLinks'] = self._serialize.query(
                'include_links', include_links, 'bool')
        response = self._send(
            http_method='GET',
            location_id='bc1f417e-239d-42e7-85e1-76e80cb2d6eb',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcBranchRef]',
                                 self._unwrap_collection(response))

    def get_changeset_changes(self, id=None, skip=None, top=None):
        """GetChangesetChanges.
        [Preview API] Retrieve Tfvc changes for a given changeset.
        :param int id: ID of the changeset. Default: null
        :param int skip: Number of results to skip. Default: null
        :param int top: The maximum number of results to return. Default: null
        :rtype: [TfvcChange]
        """
        route_values = {}
        if id is not None:
            route_values['id'] = self._serialize.url('id', id, 'int')
        query_parameters = {}
        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')
        response = self._send(
            http_method='GET',
            location_id='f32b86f2-15b9-4fe6-81b1-6f8938617ee5',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcChange]',
                                 self._unwrap_collection(response))

    def create_changeset(self, changeset, project=None):
        """CreateChangeset.
        [Preview API] Create a new changeset.
        :param :class:`<TfvcChangeset> <azure.devops.v5_1.tfvc.models.TfvcChangeset>` changeset:
        :param str project: Project ID or project name
        :rtype: :class:`<TfvcChangesetRef> <azure.devops.v5_1.tfvc.models.TfvcChangesetRef>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(changeset, 'TfvcChangeset')
        response = self._send(
            http_method='POST',
            location_id='0bc8f0a4-6bfb-42a9-ba84-139da7b99c49',
            version='5.1-preview.3',
            route_values=route_values,
            content=content)
        return self._deserialize('TfvcChangesetRef', response)

    def get_changeset(self,
                      id,
                      project=None,
                      max_change_count=None,
                      include_details=None,
                      include_work_items=None,
                      max_comment_length=None,
                      include_source_rename=None,
                      skip=None,
                      top=None,
                      orderby=None,
                      search_criteria=None):
        """GetChangeset.
        [Preview API] Retrieve a Tfvc Changeset
        :param int id: Changeset Id to retrieve.
        :param str project: Project ID or project name
        :param int max_change_count: Number of changes to return (maximum 100 changes) Default: 0
        :param bool include_details: Include policy details and check-in notes in the response. Default: false
        :param bool include_work_items: Include workitems. Default: false
        :param int max_comment_length: Include details about associated work items in the response. Default: null
        :param bool include_source_rename: Include renames.  Default: false
        :param int skip: Number of results to skip. Default: null
        :param int top: The maximum number of results to return. Default: null
        :param str orderby: Results are sorted by ID in descending order by default. Use id asc to sort by ID in ascending order.
        :param :class:`<TfvcChangesetSearchCriteria> <azure.devops.v5_1.tfvc.models.TfvcChangesetSearchCriteria>` search_criteria: Following criteria available (.itemPath, .version, .versionType, .versionOption, .author, .fromId, .toId, .fromDate, .toDate) Default: null
        :rtype: :class:`<TfvcChangeset> <azure.devops.v5_1.tfvc.models.TfvcChangeset>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if id is not None:
            route_values['id'] = self._serialize.url('id', id, 'int')
        query_parameters = {}
        if max_change_count is not None:
            query_parameters['maxChangeCount'] = self._serialize.query(
                'max_change_count', max_change_count, 'int')
        if include_details is not None:
            query_parameters['includeDetails'] = self._serialize.query(
                'include_details', include_details, 'bool')
        if include_work_items is not None:
            query_parameters['includeWorkItems'] = self._serialize.query(
                'include_work_items', include_work_items, 'bool')
        if max_comment_length is not None:
            query_parameters['maxCommentLength'] = self._serialize.query(
                'max_comment_length', max_comment_length, 'int')
        if include_source_rename is not None:
            query_parameters['includeSourceRename'] = self._serialize.query(
                'include_source_rename', include_source_rename, 'bool')
        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 orderby is not None:
            query_parameters['$orderby'] = self._serialize.query(
                'orderby', orderby, 'str')
        if search_criteria is not None:
            if search_criteria.item_path is not None:
                query_parameters[
                    'searchCriteria.itemPath'] = search_criteria.item_path
            if search_criteria.author is not None:
                query_parameters[
                    'searchCriteria.author'] = search_criteria.author
            if search_criteria.from_date is not None:
                query_parameters[
                    'searchCriteria.fromDate'] = search_criteria.from_date
            if search_criteria.to_date is not None:
                query_parameters[
                    'searchCriteria.toDate'] = search_criteria.to_date
            if search_criteria.from_id is not None:
                query_parameters[
                    'searchCriteria.fromId'] = search_criteria.from_id
            if search_criteria.to_id is not None:
                query_parameters['searchCriteria.toId'] = search_criteria.to_id
            if search_criteria.follow_renames is not None:
                query_parameters[
                    'searchCriteria.followRenames'] = search_criteria.follow_renames
            if search_criteria.include_links is not None:
                query_parameters[
                    'searchCriteria.includeLinks'] = search_criteria.include_links
            if search_criteria.mappings is not None:
                query_parameters[
                    'searchCriteria.mappings'] = search_criteria.mappings
        response = self._send(
            http_method='GET',
            location_id='0bc8f0a4-6bfb-42a9-ba84-139da7b99c49',
            version='5.1-preview.3',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('TfvcChangeset', response)

    def get_changesets(self,
                       project=None,
                       max_comment_length=None,
                       skip=None,
                       top=None,
                       orderby=None,
                       search_criteria=None):
        """GetChangesets.
        [Preview API] Retrieve Tfvc Changesets
        :param str project: Project ID or project name
        :param int max_comment_length: Include details about associated work items in the response. Default: null
        :param int skip: Number of results to skip. Default: null
        :param int top: The maximum number of results to return. Default: null
        :param str orderby: Results are sorted by ID in descending order by default. Use id asc to sort by ID in ascending order.
        :param :class:`<TfvcChangesetSearchCriteria> <azure.devops.v5_1.tfvc.models.TfvcChangesetSearchCriteria>` search_criteria: Following criteria available (.itemPath, .version, .versionType, .versionOption, .author, .fromId, .toId, .fromDate, .toDate) Default: null
        :rtype: [TfvcChangesetRef]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if max_comment_length is not None:
            query_parameters['maxCommentLength'] = self._serialize.query(
                'max_comment_length', max_comment_length, 'int')
        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 orderby is not None:
            query_parameters['$orderby'] = self._serialize.query(
                'orderby', orderby, 'str')
        if search_criteria is not None:
            if search_criteria.item_path is not None:
                query_parameters[
                    'searchCriteria.itemPath'] = search_criteria.item_path
            if search_criteria.author is not None:
                query_parameters[
                    'searchCriteria.author'] = search_criteria.author
            if search_criteria.from_date is not None:
                query_parameters[
                    'searchCriteria.fromDate'] = search_criteria.from_date
            if search_criteria.to_date is not None:
                query_parameters[
                    'searchCriteria.toDate'] = search_criteria.to_date
            if search_criteria.from_id is not None:
                query_parameters[
                    'searchCriteria.fromId'] = search_criteria.from_id
            if search_criteria.to_id is not None:
                query_parameters['searchCriteria.toId'] = search_criteria.to_id
            if search_criteria.follow_renames is not None:
                query_parameters[
                    'searchCriteria.followRenames'] = search_criteria.follow_renames
            if search_criteria.include_links is not None:
                query_parameters[
                    'searchCriteria.includeLinks'] = search_criteria.include_links
            if search_criteria.mappings is not None:
                query_parameters[
                    'searchCriteria.mappings'] = search_criteria.mappings
        response = self._send(
            http_method='GET',
            location_id='0bc8f0a4-6bfb-42a9-ba84-139da7b99c49',
            version='5.1-preview.3',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcChangesetRef]',
                                 self._unwrap_collection(response))

    def get_batched_changesets(self, changesets_request_data):
        """GetBatchedChangesets.
        [Preview API] Returns changesets for a given list of changeset Ids.
        :param :class:`<TfvcChangesetsRequestData> <azure.devops.v5_1.tfvc.models.TfvcChangesetsRequestData>` changesets_request_data: List of changeset IDs.
        :rtype: [TfvcChangesetRef]
        """
        content = self._serialize.body(changesets_request_data,
                                       'TfvcChangesetsRequestData')
        response = self._send(
            http_method='POST',
            location_id='b7e7c173-803c-4fea-9ec8-31ee35c5502a',
            version='5.1-preview.1',
            content=content)
        return self._deserialize('[TfvcChangesetRef]',
                                 self._unwrap_collection(response))

    def get_changeset_work_items(self, id=None):
        """GetChangesetWorkItems.
        [Preview API] Retrieves the work items associated with a particular changeset.
        :param int id: ID of the changeset. Default: null
        :rtype: [AssociatedWorkItem]
        """
        route_values = {}
        if id is not None:
            route_values['id'] = self._serialize.url('id', id, 'int')
        response = self._send(
            http_method='GET',
            location_id='64ae0bea-1d71-47c9-a9e5-fe73f5ea0ff4',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('[AssociatedWorkItem]',
                                 self._unwrap_collection(response))

    def get_items_batch(self, item_request_data, project=None):
        """GetItemsBatch.
        [Preview API] Post for retrieving a set of items given a list of paths or a long path. Allows for specifying the recursionLevel and version descriptors for each path.
        :param :class:`<TfvcItemRequestData> <azure.devops.v5_1.tfvc.models.TfvcItemRequestData>` item_request_data:
        :param str project: Project ID or project name
        :rtype: [[TfvcItem]]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(item_request_data,
                                       'TfvcItemRequestData')
        response = self._send(
            http_method='POST',
            location_id='fe6f827b-5f64-480f-b8af-1eca3b80e833',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[[TfvcItem]]',
                                 self._unwrap_collection(response))

    def get_items_batch_zip(self, item_request_data, project=None, **kwargs):
        """GetItemsBatchZip.
        [Preview API] Post for retrieving a set of items given a list of paths or a long path. Allows for specifying the recursionLevel and version descriptors for each path.
        :param :class:`<TfvcItemRequestData> <azure.devops.v5_1.tfvc.models.TfvcItemRequestData>` item_request_data:
        :param str project: Project ID or project name
        :rtype: object
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(item_request_data,
                                       'TfvcItemRequestData')
        response = self._send(
            http_method='POST',
            location_id='fe6f827b-5f64-480f-b8af-1eca3b80e833',
            version='5.1-preview.1',
            route_values=route_values,
            content=content,
            accept_media_type='application/zip')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)

    def get_item(self,
                 path,
                 project=None,
                 file_name=None,
                 download=None,
                 scope_path=None,
                 recursion_level=None,
                 version_descriptor=None,
                 include_content=None):
        """GetItem.
        [Preview API] Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
        :param str path: Version control path of an individual item to return.
        :param str project: Project ID or project name
        :param str file_name: file name of item returned.
        :param bool download: If true, create a downloadable attachment.
        :param str scope_path: Version control path of a folder to return multiple items.
        :param str recursion_level: None (just the item), or OneLevel (contents of a folder).
        :param :class:`<TfvcVersionDescriptor> <azure.devops.v5_1.tfvc.models.TfvcVersionDescriptor>` version_descriptor: Version descriptor.  Default is null.
        :param bool include_content: Set to true to include item content when requesting json.  Default is false.
        :rtype: :class:`<TfvcItem> <azure.devops.v5_1.tfvc.models.TfvcItem>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if path is not None:
            query_parameters['path'] = self._serialize.query(
                'path', path, 'str')
        if file_name is not None:
            query_parameters['fileName'] = self._serialize.query(
                'file_name', file_name, 'str')
        if download is not None:
            query_parameters['download'] = self._serialize.query(
                'download', download, 'bool')
        if scope_path is not None:
            query_parameters['scopePath'] = self._serialize.query(
                'scope_path', scope_path, 'str')
        if recursion_level is not None:
            query_parameters['recursionLevel'] = self._serialize.query(
                'recursion_level', recursion_level, 'str')
        if version_descriptor is not None:
            if version_descriptor.version_option is not None:
                query_parameters[
                    'versionDescriptor.versionOption'] = version_descriptor.version_option
            if version_descriptor.version_type is not None:
                query_parameters[
                    'versionDescriptor.versionType'] = version_descriptor.version_type
            if version_descriptor.version is not None:
                query_parameters[
                    'versionDescriptor.version'] = version_descriptor.version
        if include_content is not None:
            query_parameters['includeContent'] = self._serialize.query(
                'include_content', include_content, 'bool')
        response = self._send(
            http_method='GET',
            location_id='ba9fc436-9a38-4578-89d6-e4f3241f5040',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('TfvcItem', response)

    def get_item_content(self,
                         path,
                         project=None,
                         file_name=None,
                         download=None,
                         scope_path=None,
                         recursion_level=None,
                         version_descriptor=None,
                         include_content=None,
                         **kwargs):
        """GetItemContent.
        [Preview API] Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
        :param str path: Version control path of an individual item to return.
        :param str project: Project ID or project name
        :param str file_name: file name of item returned.
        :param bool download: If true, create a downloadable attachment.
        :param str scope_path: Version control path of a folder to return multiple items.
        :param str recursion_level: None (just the item), or OneLevel (contents of a folder).
        :param :class:`<TfvcVersionDescriptor> <azure.devops.v5_1.tfvc.models.TfvcVersionDescriptor>` version_descriptor: Version descriptor.  Default is null.
        :param bool include_content: Set to true to include item content when requesting json.  Default is false.
        :rtype: object
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if path is not None:
            query_parameters['path'] = self._serialize.query(
                'path', path, 'str')
        if file_name is not None:
            query_parameters['fileName'] = self._serialize.query(
                'file_name', file_name, 'str')
        if download is not None:
            query_parameters['download'] = self._serialize.query(
                'download', download, 'bool')
        if scope_path is not None:
            query_parameters['scopePath'] = self._serialize.query(
                'scope_path', scope_path, 'str')
        if recursion_level is not None:
            query_parameters['recursionLevel'] = self._serialize.query(
                'recursion_level', recursion_level, 'str')
        if version_descriptor is not None:
            if version_descriptor.version_option is not None:
                query_parameters[
                    'versionDescriptor.versionOption'] = version_descriptor.version_option
            if version_descriptor.version_type is not None:
                query_parameters[
                    'versionDescriptor.versionType'] = version_descriptor.version_type
            if version_descriptor.version is not None:
                query_parameters[
                    'versionDescriptor.version'] = version_descriptor.version
        if include_content is not None:
            query_parameters['includeContent'] = self._serialize.query(
                'include_content', include_content, 'bool')
        response = self._send(
            http_method='GET',
            location_id='ba9fc436-9a38-4578-89d6-e4f3241f5040',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            accept_media_type='application/octet-stream')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)

    def get_items(self,
                  project=None,
                  scope_path=None,
                  recursion_level=None,
                  include_links=None,
                  version_descriptor=None):
        """GetItems.
        [Preview API] Get a list of Tfvc items
        :param str project: Project ID or project name
        :param str scope_path: Version control path of a folder to return multiple items.
        :param str recursion_level: None (just the item), or OneLevel (contents of a folder).
        :param bool include_links: True to include links.
        :param :class:`<TfvcVersionDescriptor> <azure.devops.v5_1.tfvc.models.TfvcVersionDescriptor>` version_descriptor:
        :rtype: [TfvcItem]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if scope_path is not None:
            query_parameters['scopePath'] = self._serialize.query(
                'scope_path', scope_path, 'str')
        if recursion_level is not None:
            query_parameters['recursionLevel'] = self._serialize.query(
                'recursion_level', recursion_level, 'str')
        if include_links is not None:
            query_parameters['includeLinks'] = self._serialize.query(
                'include_links', include_links, 'bool')
        if version_descriptor is not None:
            if version_descriptor.version_option is not None:
                query_parameters[
                    'versionDescriptor.versionOption'] = version_descriptor.version_option
            if version_descriptor.version_type is not None:
                query_parameters[
                    'versionDescriptor.versionType'] = version_descriptor.version_type
            if version_descriptor.version is not None:
                query_parameters[
                    'versionDescriptor.version'] = version_descriptor.version
        response = self._send(
            http_method='GET',
            location_id='ba9fc436-9a38-4578-89d6-e4f3241f5040',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcItem]',
                                 self._unwrap_collection(response))

    def get_item_text(self,
                      path,
                      project=None,
                      file_name=None,
                      download=None,
                      scope_path=None,
                      recursion_level=None,
                      version_descriptor=None,
                      include_content=None,
                      **kwargs):
        """GetItemText.
        [Preview API] Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
        :param str path: Version control path of an individual item to return.
        :param str project: Project ID or project name
        :param str file_name: file name of item returned.
        :param bool download: If true, create a downloadable attachment.
        :param str scope_path: Version control path of a folder to return multiple items.
        :param str recursion_level: None (just the item), or OneLevel (contents of a folder).
        :param :class:`<TfvcVersionDescriptor> <azure.devops.v5_1.tfvc.models.TfvcVersionDescriptor>` version_descriptor: Version descriptor.  Default is null.
        :param bool include_content: Set to true to include item content when requesting json.  Default is false.
        :rtype: object
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if path is not None:
            query_parameters['path'] = self._serialize.query(
                'path', path, 'str')
        if file_name is not None:
            query_parameters['fileName'] = self._serialize.query(
                'file_name', file_name, 'str')
        if download is not None:
            query_parameters['download'] = self._serialize.query(
                'download', download, 'bool')
        if scope_path is not None:
            query_parameters['scopePath'] = self._serialize.query(
                'scope_path', scope_path, 'str')
        if recursion_level is not None:
            query_parameters['recursionLevel'] = self._serialize.query(
                'recursion_level', recursion_level, 'str')
        if version_descriptor is not None:
            if version_descriptor.version_option is not None:
                query_parameters[
                    'versionDescriptor.versionOption'] = version_descriptor.version_option
            if version_descriptor.version_type is not None:
                query_parameters[
                    'versionDescriptor.versionType'] = version_descriptor.version_type
            if version_descriptor.version is not None:
                query_parameters[
                    'versionDescriptor.version'] = version_descriptor.version
        if include_content is not None:
            query_parameters['includeContent'] = self._serialize.query(
                'include_content', include_content, 'bool')
        response = self._send(
            http_method='GET',
            location_id='ba9fc436-9a38-4578-89d6-e4f3241f5040',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            accept_media_type='text/plain')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)

    def get_item_zip(self,
                     path,
                     project=None,
                     file_name=None,
                     download=None,
                     scope_path=None,
                     recursion_level=None,
                     version_descriptor=None,
                     include_content=None,
                     **kwargs):
        """GetItemZip.
        [Preview API] Get Item Metadata and/or Content for a single item. The download parameter is to indicate whether the content should be available as a download or just sent as a stream in the response. Doesn't apply to zipped content which is always returned as a download.
        :param str path: Version control path of an individual item to return.
        :param str project: Project ID or project name
        :param str file_name: file name of item returned.
        :param bool download: If true, create a downloadable attachment.
        :param str scope_path: Version control path of a folder to return multiple items.
        :param str recursion_level: None (just the item), or OneLevel (contents of a folder).
        :param :class:`<TfvcVersionDescriptor> <azure.devops.v5_1.tfvc.models.TfvcVersionDescriptor>` version_descriptor: Version descriptor.  Default is null.
        :param bool include_content: Set to true to include item content when requesting json.  Default is false.
        :rtype: object
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if path is not None:
            query_parameters['path'] = self._serialize.query(
                'path', path, 'str')
        if file_name is not None:
            query_parameters['fileName'] = self._serialize.query(
                'file_name', file_name, 'str')
        if download is not None:
            query_parameters['download'] = self._serialize.query(
                'download', download, 'bool')
        if scope_path is not None:
            query_parameters['scopePath'] = self._serialize.query(
                'scope_path', scope_path, 'str')
        if recursion_level is not None:
            query_parameters['recursionLevel'] = self._serialize.query(
                'recursion_level', recursion_level, 'str')
        if version_descriptor is not None:
            if version_descriptor.version_option is not None:
                query_parameters[
                    'versionDescriptor.versionOption'] = version_descriptor.version_option
            if version_descriptor.version_type is not None:
                query_parameters[
                    'versionDescriptor.versionType'] = version_descriptor.version_type
            if version_descriptor.version is not None:
                query_parameters[
                    'versionDescriptor.version'] = version_descriptor.version
        if include_content is not None:
            query_parameters['includeContent'] = self._serialize.query(
                'include_content', include_content, 'bool')
        response = self._send(
            http_method='GET',
            location_id='ba9fc436-9a38-4578-89d6-e4f3241f5040',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            accept_media_type='application/zip')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)

    def get_label_items(self, label_id, top=None, skip=None):
        """GetLabelItems.
        [Preview API] Get items under a label.
        :param str label_id: Unique identifier of label
        :param int top: Max number of items to return
        :param int skip: Number of items to skip
        :rtype: [TfvcItem]
        """
        route_values = {}
        if label_id is not None:
            route_values['labelId'] = self._serialize.url(
                'label_id', label_id, 'str')
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='06166e34-de17-4b60-8cd1-23182a346fda',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcItem]',
                                 self._unwrap_collection(response))

    def get_label(self, label_id, request_data, project=None):
        """GetLabel.
        [Preview API] Get a single deep label.
        :param str label_id: Unique identifier of label
        :param :class:`<TfvcLabelRequestData> <azure.devops.v5_1.tfvc.models.TfvcLabelRequestData>` request_data: maxItemCount
        :param str project: Project ID or project name
        :rtype: :class:`<TfvcLabel> <azure.devops.v5_1.tfvc.models.TfvcLabel>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if label_id is not None:
            route_values['labelId'] = self._serialize.url(
                'label_id', label_id, 'str')
        query_parameters = {}
        if request_data is not None:
            if request_data.label_scope is not None:
                query_parameters[
                    'requestData.labelScope'] = request_data.label_scope
            if request_data.name is not None:
                query_parameters['requestData.name'] = request_data.name
            if request_data.owner is not None:
                query_parameters['requestData.owner'] = request_data.owner
            if request_data.item_label_filter is not None:
                query_parameters[
                    'requestData.itemLabelFilter'] = request_data.item_label_filter
            if request_data.max_item_count is not None:
                query_parameters[
                    'requestData.maxItemCount'] = request_data.max_item_count
            if request_data.include_links is not None:
                query_parameters[
                    'requestData.includeLinks'] = request_data.include_links
        response = self._send(
            http_method='GET',
            location_id='a5d9bd7f-b661-4d0e-b9be-d9c16affae54',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('TfvcLabel', response)

    def get_labels(self, request_data, project=None, top=None, skip=None):
        """GetLabels.
        [Preview API] Get a collection of shallow label references.
        :param :class:`<TfvcLabelRequestData> <azure.devops.v5_1.tfvc.models.TfvcLabelRequestData>` request_data: labelScope, name, owner, and itemLabelFilter
        :param str project: Project ID or project name
        :param int top: Max number of labels to return
        :param int skip: Number of labels to skip
        :rtype: [TfvcLabelRef]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if request_data is not None:
            if request_data.label_scope is not None:
                query_parameters[
                    'requestData.labelScope'] = request_data.label_scope
            if request_data.name is not None:
                query_parameters['requestData.name'] = request_data.name
            if request_data.owner is not None:
                query_parameters['requestData.owner'] = request_data.owner
            if request_data.item_label_filter is not None:
                query_parameters[
                    'requestData.itemLabelFilter'] = request_data.item_label_filter
            if request_data.max_item_count is not None:
                query_parameters[
                    'requestData.maxItemCount'] = request_data.max_item_count
            if request_data.include_links is not None:
                query_parameters[
                    'requestData.includeLinks'] = request_data.include_links
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='a5d9bd7f-b661-4d0e-b9be-d9c16affae54',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TfvcLabelRef]',
                                 self._unwrap_collection(response))

    def get_shelveset_changes(self, shelveset_id, top=None, skip=None):
        """GetShelvesetChanges.
        [Preview API] Get changes included in a shelveset.
        :param str shelveset_id: Shelveset's unique ID
        :param int top: Max number of changes to return
        :param int skip: Number of changes to skip
        :rtype: [TfvcChange]
        """
        query_parameters = {}
        if shelveset_id is not None:
            query_parameters['shelvesetId'] = self._serialize.query(
                'shelveset_id', shelveset_id, 'str')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='dbaf075b-0445-4c34-9e5b-82292f856522',
            version='5.1-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[TfvcChange]',
                                 self._unwrap_collection(response))

    def get_shelveset(self, shelveset_id, request_data=None):
        """GetShelveset.
        [Preview API] Get a single deep shelveset.
        :param str shelveset_id: Shelveset's unique ID
        :param :class:`<TfvcShelvesetRequestData> <azure.devops.v5_1.tfvc.models.TfvcShelvesetRequestData>` request_data: includeDetails, includeWorkItems, maxChangeCount, and maxCommentLength
        :rtype: :class:`<TfvcShelveset> <azure.devops.v5_1.tfvc.models.TfvcShelveset>`
        """
        query_parameters = {}
        if shelveset_id is not None:
            query_parameters['shelvesetId'] = self._serialize.query(
                'shelveset_id', shelveset_id, 'str')
        if request_data is not None:
            if request_data.name is not None:
                query_parameters['requestData.name'] = request_data.name
            if request_data.owner is not None:
                query_parameters['requestData.owner'] = request_data.owner
            if request_data.max_comment_length is not None:
                query_parameters[
                    'requestData.maxCommentLength'] = request_data.max_comment_length
            if request_data.max_change_count is not None:
                query_parameters[
                    'requestData.maxChangeCount'] = request_data.max_change_count
            if request_data.include_details is not None:
                query_parameters[
                    'requestData.includeDetails'] = request_data.include_details
            if request_data.include_work_items is not None:
                query_parameters[
                    'requestData.includeWorkItems'] = request_data.include_work_items
            if request_data.include_links is not None:
                query_parameters[
                    'requestData.includeLinks'] = request_data.include_links
        response = self._send(
            http_method='GET',
            location_id='e36d44fb-e907-4b0a-b194-f83f1ed32ad3',
            version='5.1-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('TfvcShelveset', response)

    def get_shelvesets(self, request_data=None, top=None, skip=None):
        """GetShelvesets.
        [Preview API] Return a collection of shallow shelveset references.
        :param :class:`<TfvcShelvesetRequestData> <azure.devops.v5_1.tfvc.models.TfvcShelvesetRequestData>` request_data: name, owner, and maxCommentLength
        :param int top: Max number of shelvesets to return
        :param int skip: Number of shelvesets to skip
        :rtype: [TfvcShelvesetRef]
        """
        query_parameters = {}
        if request_data is not None:
            if request_data.name is not None:
                query_parameters['requestData.name'] = request_data.name
            if request_data.owner is not None:
                query_parameters['requestData.owner'] = request_data.owner
            if request_data.max_comment_length is not None:
                query_parameters[
                    'requestData.maxCommentLength'] = request_data.max_comment_length
            if request_data.max_change_count is not None:
                query_parameters[
                    'requestData.maxChangeCount'] = request_data.max_change_count
            if request_data.include_details is not None:
                query_parameters[
                    'requestData.includeDetails'] = request_data.include_details
            if request_data.include_work_items is not None:
                query_parameters[
                    'requestData.includeWorkItems'] = request_data.include_work_items
            if request_data.include_links is not None:
                query_parameters[
                    'requestData.includeLinks'] = request_data.include_links
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='e36d44fb-e907-4b0a-b194-f83f1ed32ad3',
            version='5.1-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[TfvcShelvesetRef]',
                                 self._unwrap_collection(response))

    def get_shelveset_work_items(self, shelveset_id):
        """GetShelvesetWorkItems.
        [Preview API] Get work items associated with a shelveset.
        :param str shelveset_id: Shelveset's unique ID
        :rtype: [AssociatedWorkItem]
        """
        query_parameters = {}
        if shelveset_id is not None:
            query_parameters['shelvesetId'] = self._serialize.query(
                'shelveset_id', shelveset_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='a7a0c1c1-373e-425a-b031-a519474d743d',
            version='5.1-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[AssociatedWorkItem]',
                                 self._unwrap_collection(response))
コード例 #22
0
class PredictionEndpoint(object):
    """PredictionEndpoint

    :ivar config: Configuration for client.
    :vartype config: PredictionEndpointConfiguration

    :param api_key:
    :type api_key: str
    :param str base_url: Service URL
    """

    def __init__(
            self, api_key, base_url=None):

        self.config = PredictionEndpointConfiguration(api_key, base_url)
        self._client = ServiceClient(None, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '1.1'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def predict_image_url(
            self, project_id, iteration_id=None, application=None, url=None, custom_headers=None, raw=False, **operation_config):
        """Predict an image url and saves the result.

        :param project_id: The project id
        :type project_id: str
        :param iteration_id: Optional. Specifies the id of a particular
         iteration to evaluate against.
         The default iteration for the project will be used when not specified
        :type iteration_id: str
        :param application: Optional. Specifies the name of application using
         the endpoint
        :type application: str
        :param url:
        :type url: 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: ImagePredictionResultModel or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        image_url = models.ImageUrl(url=url)

        # Construct URL
        url = '/{projectId}/url'
        path_format_arguments = {
            'projectId': self._serialize.url("project_id", project_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

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

        # Construct body
        body_content = self._serialize.body(image_url, 'ImageUrl')

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

        deserialized = None

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

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

        return deserialized

    def predict_image(
            self, project_id, image_data, iteration_id=None, application=None, custom_headers=None, raw=False, **operation_config):
        """Predict an image and saves the result.

        :param project_id: The project id
        :type project_id: str
        :param image_data:
        :type image_data: Generator
        :param iteration_id: Optional. Specifies the id of a particular
         iteration to evaluate against.
         The default iteration for the project will be used when not specified
        :type iteration_id: str
        :param application: Optional. Specifies the name of application using
         the endpoint
        :type application: 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: ImagePredictionResultModel or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        # Construct URL
        url = '/{projectId}/image'
        path_format_arguments = {
            'projectId': self._serialize.url("project_id", project_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

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

        # Construct form data
        form_data_content = {
            'imageData': image_data,
        }

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

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

        deserialized = None

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

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

        return deserialized

    def predict_image_url_with_no_store(
            self, project_id, iteration_id=None, application=None, url=None, custom_headers=None, raw=False, **operation_config):
        """Predict an image url without saving the result.

        :param project_id: The project id
        :type project_id: str
        :param iteration_id: Optional. Specifies the id of a particular
         iteration to evaluate against.
         The default iteration for the project will be used when not specified
        :type iteration_id: str
        :param application: Optional. Specifies the name of application using
         the endpoint
        :type application: str
        :param url:
        :type url: 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: ImagePredictionResultModel or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        image_url = models.ImageUrl(url=url)

        # Construct URL
        url = '/{projectId}/url/nostore'
        path_format_arguments = {
            'projectId': self._serialize.url("project_id", project_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

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

        # Construct body
        body_content = self._serialize.body(image_url, 'ImageUrl')

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

        deserialized = None

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

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

        return deserialized

    def predict_image_with_no_store(
            self, project_id, image_data, iteration_id=None, application=None, custom_headers=None, raw=False, **operation_config):
        """Predict an image without saving the result.

        :param project_id: The project id
        :type project_id: str
        :param image_data:
        :type image_data: Generator
        :param iteration_id: Optional. Specifies the id of a particular
         iteration to evaluate against.
         The default iteration for the project will be used when not specified
        :type iteration_id: str
        :param application: Optional. Specifies the name of application using
         the endpoint
        :type application: 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: ImagePredictionResultModel or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        # Construct URL
        url = '/{projectId}/image/nostore'
        path_format_arguments = {
            'projectId': self._serialize.url("project_id", project_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

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

        # Construct form data
        form_data_content = {
            'imageData': image_data,
        }

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

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

        deserialized = None

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

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

        return deserialized
コード例 #23
0
class FormRecognizerClient(SDKClient):
    """Extracts information from forms and images into structured data based on a model created by a set of representative training forms.

    :ivar config: Configuration for client.
    :vartype config: FormRecognizerClientConfiguration

    :param endpoint: Supported Cognitive Services endpoints (protocol and
     hostname, for example: https://westus2.api.cognitive.microsoft.com).
    :type endpoint: str
    :param credentials: Subscription credentials which uniquely identify
     client subscription.
    :type credentials: None
    """

    def __init__(
            self, endpoint, credentials):

        self.config = FormRecognizerClientConfiguration(endpoint, credentials)
        super(FormRecognizerClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '1.0-preview'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def train_custom_model(
            self, source, custom_headers=None, raw=False, **operation_config):
        """Train Model.

        The train request must include a source parameter that is either an
        externally accessible Azure Storage blob container Uri (preferably a
        Shared Access Signature Uri) or valid path to a data folder in a
        locally mounted drive. When local paths are specified, they must follow
        the Linux/Unix path format and be an absolute path rooted to the input
        mount configuration
        setting value e.g., if '{Mounts:Input}' configuration setting value is
        '/input' then a valid source path would be '/input/contosodataset'. All
        data to be trained are expected to be under the source. Models are
        trained using documents that are of the following content type -
        'application/pdf', 'image/jpeg' and 'image/png'."
        Other content is ignored when training a model.

        :param source: Get or set source path.
        :type source: 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: TrainResult or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.formrecognizer.models.TrainResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.formrecognizer.models.ErrorResponseException>`
        """
        train_request = models.TrainRequest(source=source)

        # Construct URL
        url = self.train_custom_model.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 = {}

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

        # Construct body
        body_content = self._serialize.body(train_request, 'TrainRequest')

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

        deserialized = None

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

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

        return deserialized
    train_custom_model.metadata = {'url': '/custom/train'}

    def get_extracted_keys(
            self, id, custom_headers=None, raw=False, **operation_config):
        """Get Keys.

        Use the API to retrieve the keys that were
        extracted by the specified model.

        :param id: Model identifier.
        :type 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: KeysResult or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.formrecognizer.models.KeysResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.formrecognizer.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.get_extracted_keys.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'id': self._serialize.url("id", 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.ErrorResponseException(self._deserialize, response)

        deserialized = None

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

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

        return deserialized
    get_extracted_keys.metadata = {'url': '/custom/models/{id}/keys'}

    def get_custom_models(
            self, custom_headers=None, raw=False, **operation_config):
        """Get Models.

        Get information about all trained models.

        :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: ModelsResult or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.formrecognizer.models.ModelsResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.formrecognizer.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.get_custom_models.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 = {}

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

        deserialized = None

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

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

        return deserialized
    get_custom_models.metadata = {'url': '/custom/models'}

    def get_custom_model(
            self, id, custom_headers=None, raw=False, **operation_config):
        """Get Model.

        Get information about a model.

        :param id: Model identifier.
        :type 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: ModelResult or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.formrecognizer.models.ModelResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.formrecognizer.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.get_custom_model.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'id': self._serialize.url("id", 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.ErrorResponseException(self._deserialize, response)

        deserialized = None

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

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

        return deserialized
    get_custom_model.metadata = {'url': '/custom/models/{id}'}

    def delete_custom_model(
            self, id, custom_headers=None, raw=False, **operation_config):
        """Delete Model.

        Delete model artifacts.

        :param id: The identifier of the model to delete.
        :type 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:`ErrorResponseException<azure.cognitiveservices.formrecognizer.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.delete_custom_model.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'id': self._serialize.url("id", 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.delete(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
    delete_custom_model.metadata = {'url': '/custom/models/{id}'}

    def analyze_with_custom_model(
            self, id, form_stream, keys=None, custom_headers=None, raw=False, **operation_config):
        """Analyze Form.

        The document to analyze must be of a supported content type -
        'application/pdf', 'image/jpeg' or 'image/png'. The response contains
        not just the extracted information of the analyzed form but also
        information about content that was not extracted along with a reason.

        :param id: Model Identifier to analyze the document with.
        :type id: str
        :param form_stream: A pdf document or image (jpg,png) file to analyze.
        :type form_stream: Generator
        :param keys: An optional list of known keys to extract the values for.
        :type keys: list[str]
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: AnalyzeResult or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.formrecognizer.models.AnalyzeResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.formrecognizer.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.analyze_with_custom_model.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'id': self._serialize.url("id", id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct form data
        form_data_content = {
            'form_stream': form_stream,
        }

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

        deserialized = None

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

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

        return deserialized
    analyze_with_custom_model.metadata = {'url': '/custom/models/{id}/analyze'}
コード例 #24
0
class NetworkManagementClient(object):
    """Composite Swagger for Network Client

    :ivar config: Configuration for client.
    :vartype config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: .operations.ApplicationGatewaysOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: .operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: .operations.RoutesOperations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: .operations.PublicIPAddressesOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: .operations.NetworkSecurityGroupsOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: .operations.SecurityRulesOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: .operations.LoadBalancersOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: .operations.VirtualNetworksOperations
    :ivar subnets: Subnets operations
    :vartype subnets: .operations.SubnetsOperations
    :ivar virtual_network_peerings: VirtualNetworkPeerings operations
    :vartype virtual_network_peerings: .operations.VirtualNetworkPeeringsOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: .operations.NetworkInterfacesOperations
    :ivar usages: Usages operations
    :vartype usages: .operations.UsagesOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: .operations.VirtualNetworkGatewaysOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: .operations.VirtualNetworkGatewayConnectionsOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: .operations.LocalNetworkGatewaysOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: .operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: .operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: .operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: .operations.ExpressRouteServiceProvidersOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription credentials which uniquely
     identify the Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param accept_language: Gets or sets the preferred language for the
     response.
    :type accept_language: str
    :param long_running_operation_retry_timeout: Gets or sets the retry
     timeout in seconds for Long Running Operations. Default value is 30.
    :type long_running_operation_retry_timeout: int
    :param generate_client_request_id: When set to true a unique
     x-ms-client-request-id value is generated and included in each request.
     Default is true.
    :type generate_client_request_id: bool
    :param str base_url: Service URL
    :param str filepath: Existing config
    """

    def __init__(
            self, credentials, subscription_id, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):

        self.config = NetworkManagementClientConfiguration(credentials, subscription_id, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.routes = RoutesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_peerings = VirtualNetworkPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(
            self, location, domain_name_label=None, custom_headers=None, raw=False, **operation_config):
        """Checks whether a domain name in the cloudapp.net zone is available for
        use.

        :param location: The location of the domain name.
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: 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>`.
        :rtype: :class:`DnsNameAvailabilityResult
         <azure.mgmt.network.models.DnsNameAvailabilityResult>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-09-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'
        path_format_arguments = {
            'location': self._serialize.url("location", location, '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 = {}
        if domain_name_label is not None:
            query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query("api_version", 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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
コード例 #25
0
class IdentityClient(VssClient):
    """Identity
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(IdentityClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '8a3d49b8-91f0-46ef-b33d-dda338c25db3'

    def create_or_bind_with_claims(self, source_identity):
        """CreateOrBindWithClaims.
        [Preview API]
        :param :class:`<Identity> <identity.v4_0.models.Identity>` source_identity:
        :rtype: :class:`<Identity> <identity.v4_0.models.Identity>`
        """
        content = self._serialize.body(source_identity, 'Identity')
        response = self._send(
            http_method='PUT',
            location_id='90ddfe71-171c-446c-bf3b-b597cd562afd',
            version='4.0-preview.1',
            content=content)
        return self._deserialize('Identity', response)

    def get_descriptor_by_id(self, id, is_master_id=None):
        """GetDescriptorById.
        [Preview API]
        :param str id:
        :param bool is_master_id:
        :rtype: :class:`<str> <identity.v4_0.models.str>`
        """
        route_values = {}
        if id is not None:
            route_values['id'] = self._serialize.url('id', id, 'str')
        query_parameters = {}
        if is_master_id is not None:
            query_parameters['isMasterId'] = self._serialize.query(
                'is_master_id', is_master_id, 'bool')
        response = self._send(
            http_method='GET',
            location_id='a230389a-94f2-496c-839f-c929787496dd',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('str', response)

    def create_groups(self, container):
        """CreateGroups.
        :param :class:`<object> <identity.v4_0.models.object>` container:
        :rtype: [Identity]
        """
        content = self._serialize.body(container, 'object')
        response = self._send(
            http_method='POST',
            location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
            version='4.0',
            content=content)
        return self._deserialize('[Identity]',
                                 self._unwrap_collection(response))

    def delete_group(self, group_id):
        """DeleteGroup.
        :param str group_id:
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        self._send(http_method='DELETE',
                   location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                   version='4.0',
                   route_values=route_values)

    def list_groups(self,
                    scope_ids=None,
                    recurse=None,
                    deleted=None,
                    properties=None):
        """ListGroups.
        :param str scope_ids:
        :param bool recurse:
        :param bool deleted:
        :param str properties:
        :rtype: [Identity]
        """
        query_parameters = {}
        if scope_ids is not None:
            query_parameters['scopeIds'] = self._serialize.query(
                'scope_ids', scope_ids, 'str')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query(
                'recurse', recurse, 'bool')
        if deleted is not None:
            query_parameters['deleted'] = self._serialize.query(
                'deleted', deleted, 'bool')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query(
                'properties', properties, 'str')
        response = self._send(
            http_method='GET',
            location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
            version='4.0',
            query_parameters=query_parameters)
        return self._deserialize('[Identity]',
                                 self._unwrap_collection(response))

    def get_identity_changes(self,
                             identity_sequence_id,
                             group_sequence_id,
                             scope_id=None):
        """GetIdentityChanges.
        :param int identity_sequence_id:
        :param int group_sequence_id:
        :param str scope_id:
        :rtype: :class:`<ChangedIdentities> <identity.v4_0.models.ChangedIdentities>`
        """
        query_parameters = {}
        if identity_sequence_id is not None:
            query_parameters['identitySequenceId'] = self._serialize.query(
                'identity_sequence_id', identity_sequence_id, 'int')
        if group_sequence_id is not None:
            query_parameters['groupSequenceId'] = self._serialize.query(
                'group_sequence_id', group_sequence_id, 'int')
        if scope_id is not None:
            query_parameters['scopeId'] = self._serialize.query(
                'scope_id', scope_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
            version='4.0',
            query_parameters=query_parameters)
        return self._deserialize('ChangedIdentities', response)

    def get_user_identity_ids_by_domain_id(self, domain_id):
        """GetUserIdentityIdsByDomainId.
        :param str domain_id:
        :rtype: [str]
        """
        query_parameters = {}
        if domain_id is not None:
            query_parameters['domainId'] = self._serialize.query(
                'domain_id', domain_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
            version='4.0',
            query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))

    def read_identities(self,
                        descriptors=None,
                        identity_ids=None,
                        search_filter=None,
                        filter_value=None,
                        query_membership=None,
                        properties=None,
                        include_restricted_visibility=None,
                        options=None):
        """ReadIdentities.
        :param str descriptors:
        :param str identity_ids:
        :param str search_filter:
        :param str filter_value:
        :param str query_membership:
        :param str properties:
        :param bool include_restricted_visibility:
        :param str options:
        :rtype: [Identity]
        """
        query_parameters = {}
        if descriptors is not None:
            query_parameters['descriptors'] = self._serialize.query(
                'descriptors', descriptors, 'str')
        if identity_ids is not None:
            query_parameters['identityIds'] = self._serialize.query(
                'identity_ids', identity_ids, 'str')
        if search_filter is not None:
            query_parameters['searchFilter'] = self._serialize.query(
                'search_filter', search_filter, 'str')
        if filter_value is not None:
            query_parameters['filterValue'] = self._serialize.query(
                'filter_value', filter_value, 'str')
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query(
                'properties', properties, 'str')
        if include_restricted_visibility is not None:
            query_parameters[
                'includeRestrictedVisibility'] = self._serialize.query(
                    'include_restricted_visibility',
                    include_restricted_visibility, 'bool')
        if options is not None:
            query_parameters['options'] = self._serialize.query(
                'options', options, 'str')
        response = self._send(
            http_method='GET',
            location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
            version='4.0',
            query_parameters=query_parameters)
        return self._deserialize('[Identity]',
                                 self._unwrap_collection(response))

    def read_identities_by_scope(self,
                                 scope_id,
                                 query_membership=None,
                                 properties=None):
        """ReadIdentitiesByScope.
        :param str scope_id:
        :param str query_membership:
        :param str properties:
        :rtype: [Identity]
        """
        query_parameters = {}
        if scope_id is not None:
            query_parameters['scopeId'] = self._serialize.query(
                'scope_id', scope_id, 'str')
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query(
                'properties', properties, 'str')
        response = self._send(
            http_method='GET',
            location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
            version='4.0',
            query_parameters=query_parameters)
        return self._deserialize('[Identity]',
                                 self._unwrap_collection(response))

    def read_identity(self,
                      identity_id,
                      query_membership=None,
                      properties=None):
        """ReadIdentity.
        :param str identity_id:
        :param str query_membership:
        :param str properties:
        :rtype: :class:`<Identity> <identity.v4_0.models.Identity>`
        """
        route_values = {}
        if identity_id is not None:
            route_values['identityId'] = self._serialize.url(
                'identity_id', identity_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query(
                'properties', properties, 'str')
        response = self._send(
            http_method='GET',
            location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
            version='4.0',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('Identity', response)

    def update_identities(self, identities):
        """UpdateIdentities.
        :param :class:`<VssJsonCollectionWrapper> <identity.v4_0.models.VssJsonCollectionWrapper>` identities:
        :rtype: [IdentityUpdateData]
        """
        content = self._serialize.body(identities, 'VssJsonCollectionWrapper')
        response = self._send(
            http_method='PUT',
            location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
            version='4.0',
            content=content)
        return self._deserialize('[IdentityUpdateData]',
                                 self._unwrap_collection(response))

    def update_identity(self, identity, identity_id):
        """UpdateIdentity.
        :param :class:`<Identity> <identity.v4_0.models.Identity>` identity:
        :param str identity_id:
        """
        route_values = {}
        if identity_id is not None:
            route_values['identityId'] = self._serialize.url(
                'identity_id', identity_id, 'str')
        content = self._serialize.body(identity, 'Identity')
        self._send(http_method='PUT',
                   location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                   version='4.0',
                   route_values=route_values,
                   content=content)

    def create_identity(self, framework_identity_info):
        """CreateIdentity.
        :param :class:`<FrameworkIdentityInfo> <identity.v4_0.models.FrameworkIdentityInfo>` framework_identity_info:
        :rtype: :class:`<Identity> <identity.v4_0.models.Identity>`
        """
        content = self._serialize.body(framework_identity_info,
                                       'FrameworkIdentityInfo')
        response = self._send(
            http_method='PUT',
            location_id='dd55f0eb-6ea2-4fe4-9ebe-919e7dd1dfb4',
            version='4.0',
            content=content)
        return self._deserialize('Identity', response)

    def read_identity_batch(self, batch_info):
        """ReadIdentityBatch.
        [Preview API]
        :param :class:`<IdentityBatchInfo> <identity.v4_0.models.IdentityBatchInfo>` batch_info:
        :rtype: [Identity]
        """
        content = self._serialize.body(batch_info, 'IdentityBatchInfo')
        response = self._send(
            http_method='POST',
            location_id='299e50df-fe45-4d3a-8b5b-a5836fac74dc',
            version='4.0-preview.1',
            content=content)
        return self._deserialize('[Identity]',
                                 self._unwrap_collection(response))

    def get_identity_snapshot(self, scope_id):
        """GetIdentitySnapshot.
        [Preview API]
        :param str scope_id:
        :rtype: :class:`<IdentitySnapshot> <identity.v4_0.models.IdentitySnapshot>`
        """
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url(
                'scope_id', scope_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='d56223df-8ccd-45c9-89b4-eddf692400d7',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('IdentitySnapshot', response)

    def get_max_sequence_id(self):
        """GetMaxSequenceId.
        Read the max sequence id of all the identities.
        :rtype: long
        """
        response = self._send(
            http_method='GET',
            location_id='e4a70778-cb2c-4e85-b7cc-3f3c7ae2d408',
            version='4.0')
        return self._deserialize('long', response)

    def get_self(self):
        """GetSelf.
        Read identity of the home tenant request user.
        :rtype: :class:`<IdentitySelf> <identity.v4_0.models.IdentitySelf>`
        """
        response = self._send(
            http_method='GET',
            location_id='4bb02b5b-c120-4be2-b68e-21f7c50a4b82',
            version='4.0')
        return self._deserialize('IdentitySelf', response)

    def add_member(self, container_id, member_id):
        """AddMember.
        [Preview API]
        :param str container_id:
        :param str member_id:
        :rtype: bool
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url(
                'container_id', container_id, 'str')
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        response = self._send(
            http_method='PUT',
            location_id='8ba35978-138e-41f8-8963-7b1ea2c5f775',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('bool', response)

    def read_member(self, container_id, member_id, query_membership=None):
        """ReadMember.
        [Preview API]
        :param str container_id:
        :param str member_id:
        :param str query_membership:
        :rtype: :class:`<str> <identity.v4_0.models.str>`
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url(
                'container_id', container_id, 'str')
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        response = self._send(
            http_method='GET',
            location_id='8ba35978-138e-41f8-8963-7b1ea2c5f775',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('str', response)

    def read_members(self, container_id, query_membership=None):
        """ReadMembers.
        [Preview API]
        :param str container_id:
        :param str query_membership:
        :rtype: [str]
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url(
                'container_id', container_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        response = self._send(
            http_method='GET',
            location_id='8ba35978-138e-41f8-8963-7b1ea2c5f775',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))

    def remove_member(self, container_id, member_id):
        """RemoveMember.
        [Preview API]
        :param str container_id:
        :param str member_id:
        :rtype: bool
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url(
                'container_id', container_id, 'str')
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        response = self._send(
            http_method='DELETE',
            location_id='8ba35978-138e-41f8-8963-7b1ea2c5f775',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('bool', response)

    def read_member_of(self, member_id, container_id, query_membership=None):
        """ReadMemberOf.
        [Preview API]
        :param str member_id:
        :param str container_id:
        :param str query_membership:
        :rtype: :class:`<str> <identity.v4_0.models.str>`
        """
        route_values = {}
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        if container_id is not None:
            route_values['containerId'] = self._serialize.url(
                'container_id', container_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        response = self._send(
            http_method='GET',
            location_id='22865b02-9e4a-479e-9e18-e35b8803b8a0',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('str', response)

    def read_members_of(self, member_id, query_membership=None):
        """ReadMembersOf.
        [Preview API]
        :param str member_id:
        :param str query_membership:
        :rtype: [str]
        """
        route_values = {}
        if member_id is not None:
            route_values['memberId'] = self._serialize.url(
                'member_id', member_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query(
                'query_membership', query_membership, 'str')
        response = self._send(
            http_method='GET',
            location_id='22865b02-9e4a-479e-9e18-e35b8803b8a0',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))

    def create_scope(self, info, scope_id):
        """CreateScope.
        [Preview API]
        :param :class:`<CreateScopeInfo> <identity.v4_0.models.CreateScopeInfo>` info:
        :param str scope_id:
        :rtype: :class:`<IdentityScope> <identity.v4_0.models.IdentityScope>`
        """
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url(
                'scope_id', scope_id, 'str')
        content = self._serialize.body(info, 'CreateScopeInfo')
        response = self._send(
            http_method='PUT',
            location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('IdentityScope', response)

    def delete_scope(self, scope_id):
        """DeleteScope.
        [Preview API]
        :param str scope_id:
        """
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url(
                'scope_id', scope_id, 'str')
        self._send(http_method='DELETE',
                   location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
                   version='4.0-preview.1',
                   route_values=route_values)

    def get_scope_by_id(self, scope_id):
        """GetScopeById.
        [Preview API]
        :param str scope_id:
        :rtype: :class:`<IdentityScope> <identity.v4_0.models.IdentityScope>`
        """
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url(
                'scope_id', scope_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('IdentityScope', response)

    def get_scope_by_name(self, scope_name):
        """GetScopeByName.
        [Preview API]
        :param str scope_name:
        :rtype: :class:`<IdentityScope> <identity.v4_0.models.IdentityScope>`
        """
        query_parameters = {}
        if scope_name is not None:
            query_parameters['scopeName'] = self._serialize.query(
                'scope_name', scope_name, 'str')
        response = self._send(
            http_method='GET',
            location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
            version='4.0-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('IdentityScope', response)

    def rename_scope(self, rename_scope, scope_id):
        """RenameScope.
        [Preview API]
        :param :class:`<IdentityScope> <identity.v4_0.models.IdentityScope>` rename_scope:
        :param str scope_id:
        """
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url(
                'scope_id', scope_id, 'str')
        content = self._serialize.body(rename_scope, 'IdentityScope')
        self._send(http_method='PATCH',
                   location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
                   version='4.0-preview.1',
                   route_values=route_values,
                   content=content)

    def get_signed_in_token(self):
        """GetSignedInToken.
        [Preview API]
        :rtype: :class:`<AccessTokenResult> <identity.v4_0.models.AccessTokenResult>`
        """
        response = self._send(
            http_method='GET',
            location_id='6074ff18-aaad-4abb-a41e-5c75f6178057',
            version='4.0-preview.1')
        return self._deserialize('AccessTokenResult', response)

    def get_signout_token(self):
        """GetSignoutToken.
        [Preview API]
        :rtype: :class:`<AccessTokenResult> <identity.v4_0.models.AccessTokenResult>`
        """
        response = self._send(
            http_method='GET',
            location_id='be39e83c-7529-45e9-9c67-0410885880da',
            version='4.0-preview.1')
        return self._deserialize('AccessTokenResult', response)

    def get_tenant(self, tenant_id):
        """GetTenant.
        [Preview API]
        :param str tenant_id:
        :rtype: :class:`<TenantInfo> <identity.v4_0.models.TenantInfo>`
        """
        route_values = {}
        if tenant_id is not None:
            route_values['tenantId'] = self._serialize.url(
                'tenant_id', tenant_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='5f0a1723-2e2c-4c31-8cae-002d01bdd592',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('TenantInfo', response)
コード例 #26
0
class FrontDoorManagementClient(SDKClient):
    """FrontDoor Client

    :ivar config: Configuration for client.
    :vartype config: FrontDoorManagementClientConfiguration

    :ivar front_doors: FrontDoors operations
    :vartype front_doors: azure.mgmt.frontdoor.operations.FrontDoorsOperations
    :ivar routing_rules: RoutingRules operations
    :vartype routing_rules: azure.mgmt.frontdoor.operations.RoutingRulesOperations
    :ivar health_probe_settings: HealthProbeSettings operations
    :vartype health_probe_settings: azure.mgmt.frontdoor.operations.HealthProbeSettingsOperations
    :ivar load_balancing_settings: LoadBalancingSettings operations
    :vartype load_balancing_settings: azure.mgmt.frontdoor.operations.LoadBalancingSettingsOperations
    :ivar backend_pools: BackendPools operations
    :vartype backend_pools: azure.mgmt.frontdoor.operations.BackendPoolsOperations
    :ivar frontend_endpoints: FrontendEndpoints operations
    :vartype frontend_endpoints: azure.mgmt.frontdoor.operations.FrontendEndpointsOperations
    :ivar endpoints: Endpoints operations
    :vartype endpoints: azure.mgmt.frontdoor.operations.EndpointsOperations
    :ivar policies: Policies operations
    :vartype policies: azure.mgmt.frontdoor.operations.PoliciesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription credentials which uniquely
     identify the Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = FrontDoorManagementClientConfiguration(credentials, subscription_id, base_url)
        super(FrontDoorManagementClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.front_doors = FrontDoorsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.routing_rules = RoutingRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.health_probe_settings = HealthProbeSettingsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancing_settings = LoadBalancingSettingsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.backend_pools = BackendPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.frontend_endpoints = FrontendEndpointsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.endpoints = EndpointsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.policies = PoliciesOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_front_door_name_availability(
            self, name, type, custom_headers=None, raw=False, **operation_config):
        """Check the availability of a Front Door resource name.

        :param name: The resource name to validate.
        :type name: str
        :param type: The type of the resource whose name is to be validated.
         Possible values include: 'Microsoft.Network/frontDoors',
         'Microsoft.Network/frontDoors/frontendEndpoints'
        :type type: str or ~azure.mgmt.frontdoor.models.ResourceType
        :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: CheckNameAvailabilityOutput or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>`
        """
        check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type)

        api_version = "2018-08-01"

        # Construct URL
        url = self.check_front_door_name_availability.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(check_front_door_name_availability_input, 'CheckNameAvailabilityInput')

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

        deserialized = None

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

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

        return deserialized
    check_front_door_name_availability.metadata = {'url': '/providers/Microsoft.Network/checkFrontDoorNameAvailability'}

    def check_front_door_name_availability_with_subscription(
            self, name, type, custom_headers=None, raw=False, **operation_config):
        """Check the availability of a Front Door subdomain.

        :param name: The resource name to validate.
        :type name: str
        :param type: The type of the resource whose name is to be validated.
         Possible values include: 'Microsoft.Network/frontDoors',
         'Microsoft.Network/frontDoors/frontendEndpoints'
        :type type: str or ~azure.mgmt.frontdoor.models.ResourceType
        :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: CheckNameAvailabilityOutput or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>`
        """
        check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type)

        api_version = "2018-08-01"

        # Construct URL
        url = self.check_front_door_name_availability_with_subscription.metadata['url']
        path_format_arguments = {
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(check_front_door_name_availability_input, 'CheckNameAvailabilityInput')

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

        deserialized = None

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

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

        return deserialized
    check_front_door_name_availability_with_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/checkFrontDoorNameAvailability'}
コード例 #27
0
class MavenClient(Client):
    """Maven
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """

    def __init__(self, base_url=None, creds=None):
        super(MavenClient, self).__init__(base_url, creds)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '6f7f8c07-ff36-473c-bcf3-bd6cc9b6c066'

    def download_package(self, feed_id, group_id, artifact_id, version, file_name):
        """DownloadPackage.
        [Preview API] Fulfills maven package file download requests by returning the url of the package file requested.
        :param str feed_id: Name or ID of the feed.
        :param str group_id: GroupId of the maven package
        :param str artifact_id: ArtifactId of the maven package
        :param str version: Version of the package
        :param str file_name: File name to download
        :rtype: object
        """
        route_values = {}
        if feed_id is not None:
            route_values['feedId'] = self._serialize.url('feed_id', feed_id, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        if artifact_id is not None:
            route_values['artifactId'] = self._serialize.url('artifact_id', artifact_id, 'str')
        if version is not None:
            route_values['version'] = self._serialize.url('version', version, 'str')
        if file_name is not None:
            route_values['fileName'] = self._serialize.url('file_name', file_name, 'str')
        response = self._send(http_method='GET',
                              location_id='c338d4b5-d30a-47e2-95b7-f157ef558833',
                              version='5.1-preview.1',
                              route_values=route_values)
        return self._deserialize('object', response)

    def delete_package_version_from_recycle_bin(self, feed, group_id, artifact_id, version):
        """DeletePackageVersionFromRecycleBin.
        [Preview API] Permanently delete a package from a feed's recycle bin.
        :param str feed: Name or ID of the feed.
        :param str group_id: Group ID of the package.
        :param str artifact_id: Artifact ID of the package.
        :param str version: Version of the package.
        """
        route_values = {}
        if feed is not None:
            route_values['feed'] = self._serialize.url('feed', feed, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        if artifact_id is not None:
            route_values['artifactId'] = self._serialize.url('artifact_id', artifact_id, 'str')
        if version is not None:
            route_values['version'] = self._serialize.url('version', version, 'str')
        self._send(http_method='DELETE',
                   location_id='f67e10eb-1254-4953-add7-d49b83a16c9f',
                   version='5.1-preview.1',
                   route_values=route_values)

    def get_package_version_metadata_from_recycle_bin(self, feed, group_id, artifact_id, version):
        """GetPackageVersionMetadataFromRecycleBin.
        [Preview API] Get information about a package version in the recycle bin.
        :param str feed: Name or ID of the feed.
        :param str group_id: Group ID of the package.
        :param str artifact_id: Artifact ID of the package.
        :param str version: Version of the package.
        :rtype: :class:`<MavenPackageVersionDeletionState> <azure.devops.v5_1.maven.models.MavenPackageVersionDeletionState>`
        """
        route_values = {}
        if feed is not None:
            route_values['feed'] = self._serialize.url('feed', feed, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        if artifact_id is not None:
            route_values['artifactId'] = self._serialize.url('artifact_id', artifact_id, 'str')
        if version is not None:
            route_values['version'] = self._serialize.url('version', version, 'str')
        response = self._send(http_method='GET',
                              location_id='f67e10eb-1254-4953-add7-d49b83a16c9f',
                              version='5.1-preview.1',
                              route_values=route_values)
        return self._deserialize('MavenPackageVersionDeletionState', response)

    def restore_package_version_from_recycle_bin(self, package_version_details, feed, group_id, artifact_id, version):
        """RestorePackageVersionFromRecycleBin.
        [Preview API] Restore a package version from the recycle bin to its associated feed.
        :param :class:`<MavenRecycleBinPackageVersionDetails> <azure.devops.v5_1.maven.models.MavenRecycleBinPackageVersionDetails>` package_version_details: Set the 'Deleted' property to false to restore the package.
        :param str feed: Name or ID of the feed.
        :param str group_id: Group ID of the package.
        :param str artifact_id: Artifact ID of the package.
        :param str version: Version of the package.
        """
        route_values = {}
        if feed is not None:
            route_values['feed'] = self._serialize.url('feed', feed, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        if artifact_id is not None:
            route_values['artifactId'] = self._serialize.url('artifact_id', artifact_id, 'str')
        if version is not None:
            route_values['version'] = self._serialize.url('version', version, 'str')
        content = self._serialize.body(package_version_details, 'MavenRecycleBinPackageVersionDetails')
        self._send(http_method='PATCH',
                   location_id='f67e10eb-1254-4953-add7-d49b83a16c9f',
                   version='5.1-preview.1',
                   route_values=route_values,
                   content=content)

    def get_package_version(self, feed, group_id, artifact_id, version, show_deleted=None):
        """GetPackageVersion.
        [Preview API] Get information about a package version.
        :param str feed: Name or ID of the feed.
        :param str group_id: Group ID of the package.
        :param str artifact_id: Artifact ID of the package.
        :param str version: Version of the package.
        :param bool show_deleted: True to show information for deleted packages.
        :rtype: :class:`<Package> <azure.devops.v5_1.maven.models.Package>`
        """
        route_values = {}
        if feed is not None:
            route_values['feed'] = self._serialize.url('feed', feed, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        if artifact_id is not None:
            route_values['artifactId'] = self._serialize.url('artifact_id', artifact_id, 'str')
        if version is not None:
            route_values['version'] = self._serialize.url('version', version, 'str')
        query_parameters = {}
        if show_deleted is not None:
            query_parameters['showDeleted'] = self._serialize.query('show_deleted', show_deleted, 'bool')
        response = self._send(http_method='GET',
                              location_id='180ed967-377a-4112-986b-607adb14ded4',
                              version='5.1-preview.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('Package', response)

    def package_delete(self, feed, group_id, artifact_id, version):
        """PackageDelete.
        [Preview API] Delete a package version from the feed and move it to the feed's recycle bin.
        :param str feed: Name or ID of the feed.
        :param str group_id: Group ID of the package.
        :param str artifact_id: Artifact ID of the package.
        :param str version: Version of the package.
        """
        route_values = {}
        if feed is not None:
            route_values['feed'] = self._serialize.url('feed', feed, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        if artifact_id is not None:
            route_values['artifactId'] = self._serialize.url('artifact_id', artifact_id, 'str')
        if version is not None:
            route_values['version'] = self._serialize.url('version', version, 'str')
        self._send(http_method='DELETE',
                   location_id='180ed967-377a-4112-986b-607adb14ded4',
                   version='5.1-preview.1',
                   route_values=route_values)
コード例 #28
0
class CustomVisionPredictionClient(SDKClient):
    """CustomVisionPredictionClient

    :ivar config: Configuration for client.
    :vartype config: CustomVisionPredictionClientConfiguration

    :param api_key: API key.
    :type api_key: str
    :param endpoint: Supported Cognitive Services endpoints.
    :type endpoint: str
    """

    def __init__(
            self, api_key, endpoint):

        self.config = CustomVisionPredictionClientConfiguration(api_key, endpoint)
        super(CustomVisionPredictionClient, self).__init__(None, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '3.0'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def classify_image_url(
            self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config):
        """Classify an image url and saves the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param url: Url of the image.
        :type url: str
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: 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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        image_url = models.ImageUrl(url=url)

        # Construct URL
        url = self.classify_image_url.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if application is not None:
            query_parameters['application'] = self._serialize.query("application", application, '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['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct body
        body_content = self._serialize.body(image_url, 'ImageUrl')

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

        deserialized = None

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

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

        return deserialized
    classify_image_url.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/url'}

    def classify_image(
            self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config):
        """Classify an image and saves the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param image_data: Binary image data. Supported formats are JPEG, GIF,
         PNG, and BMP. Supports images up to 4MB.
        :type image_data: Generator
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: str
        :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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        # Construct URL
        url = self.classify_image.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct form data
        form_data_content = {
            'imageData': image_data,
        }

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

        deserialized = None

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

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

        return deserialized
    classify_image.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/image'}

    def classify_image_url_with_no_store(
            self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config):
        """Classify an image url without saving the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param url: Url of the image.
        :type url: str
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: 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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        image_url = models.ImageUrl(url=url)

        # Construct URL
        url = self.classify_image_url_with_no_store.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if application is not None:
            query_parameters['application'] = self._serialize.query("application", application, '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['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct body
        body_content = self._serialize.body(image_url, 'ImageUrl')

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

        deserialized = None

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

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

        return deserialized
    classify_image_url_with_no_store.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/url/nostore'}

    def classify_image_with_no_store(
            self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config):
        """Classify an image without saving the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param image_data: Binary image data. Supported formats are JPEG, GIF,
         PNG, and BMP. Supports images up to 0MB.
        :type image_data: Generator
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: 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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        # Construct URL
        url = self.classify_image_with_no_store.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct form data
        form_data_content = {
            'imageData': image_data,
        }

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

        deserialized = None

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

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

        return deserialized
    classify_image_with_no_store.metadata = {'url': '/{projectId}/classify/iterations/{publishedName}/image/nostore'}

    def detect_image_url(
            self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config):
        """Detect objects in an image url and saves the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param url: Url of the image.
        :type url: str
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: 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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        image_url = models.ImageUrl(url=url)

        # Construct URL
        url = self.detect_image_url.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if application is not None:
            query_parameters['application'] = self._serialize.query("application", application, '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['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct body
        body_content = self._serialize.body(image_url, 'ImageUrl')

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

        deserialized = None

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

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

        return deserialized
    detect_image_url.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/url'}

    def detect_image(
            self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config):
        """Detect objects in an image and saves the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param image_data: Binary image data. Supported formats are JPEG, GIF,
         PNG, and BMP. Supports images up to 4MB.
        :type image_data: Generator
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: str
        :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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        # Construct URL
        url = self.detect_image.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct form data
        form_data_content = {
            'imageData': image_data,
        }

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

        deserialized = None

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

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

        return deserialized
    detect_image.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/image'}

    def detect_image_url_with_no_store(
            self, project_id, published_name, url, application=None, custom_headers=None, raw=False, **operation_config):
        """Detect objects in an image url without saving the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param url: Url of the image.
        :type url: str
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: 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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        image_url = models.ImageUrl(url=url)

        # Construct URL
        url = self.detect_image_url_with_no_store.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        if application is not None:
            query_parameters['application'] = self._serialize.query("application", application, '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['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct body
        body_content = self._serialize.body(image_url, 'ImageUrl')

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

        deserialized = None

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

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

        return deserialized
    detect_image_url_with_no_store.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/url/nostore'}

    def detect_image_with_no_store(
            self, project_id, published_name, image_data, application=None, custom_headers=None, raw=False, **operation_config):
        """Detect objects in an image without saving the result.

        :param project_id: The project id.
        :type project_id: str
        :param published_name: Specifies the name of the model to evaluate
         against.
        :type published_name: str
        :param image_data: Binary image data. Supported formats are JPEG, GIF,
         PNG, and BMP. Supports images up to 0MB.
        :type image_data: Generator
        :param application: Optional. Specifies the name of application using
         the endpoint.
        :type application: 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: ImagePrediction or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePrediction
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`CustomVisionErrorException<azure.cognitiveservices.vision.customvision.prediction.models.CustomVisionErrorException>`
        """
        # Construct URL
        url = self.detect_image_with_no_store.metadata['url']
        path_format_arguments = {
            'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True),
            'projectId': self._serialize.url("project_id", project_id, 'str'),
            'publishedName': self._serialize.url("published_name", published_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

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

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'multipart/form-data'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str')

        # Construct form data
        form_data_content = {
            'imageData': image_data,
        }

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

        deserialized = None

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

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

        return deserialized
    detect_image_with_no_store.metadata = {'url': '/{projectId}/detect/iterations/{publishedName}/image/nostore'}
コード例 #29
0
class PolicyClient(Client):
    """Policy
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(PolicyClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = 'fb13a388-40dd-4a04-b530-013a739c72ef'

    def create_policy_configuration(self,
                                    configuration,
                                    project,
                                    configuration_id=None):
        """CreatePolicyConfiguration.
        Create a policy configuration of a given policy type.
        :param :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>` configuration: The policy configuration to create.
        :param str project: Project ID or project name
        :param int configuration_id:
        :rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        content = self._serialize.body(configuration, 'PolicyConfiguration')
        response = self._send(
            http_method='POST',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='5.1',
            route_values=route_values,
            content=content)
        return self._deserialize('PolicyConfiguration', response)

    def delete_policy_configuration(self, project, configuration_id):
        """DeletePolicyConfiguration.
        Delete a policy configuration by its ID.
        :param str project: Project ID or project name
        :param int configuration_id: ID of the policy configuration to delete.
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        self._send(http_method='DELETE',
                   location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
                   version='5.1',
                   route_values=route_values)

    def get_policy_configuration(self, project, configuration_id):
        """GetPolicyConfiguration.
        Get a policy configuration by its ID.
        :param str project: Project ID or project name
        :param int configuration_id: ID of the policy configuration
        :rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='5.1',
            route_values=route_values)
        return self._deserialize('PolicyConfiguration', response)

    def get_policy_configurations(self, project, scope=None, policy_type=None):
        """GetPolicyConfigurations.
        Get a list of policy configurations in a project.
        :param str project: Project ID or project name
        :param str scope: [Provided for legacy reasons] The scope on which a subset of policies is defined.
        :param str policy_type: Filter returned policies to only this type
        :rtype: [PolicyConfiguration]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if scope is not None:
            query_parameters['scope'] = self._serialize.query(
                'scope', scope, 'str')
        if policy_type is not None:
            query_parameters['policyType'] = self._serialize.query(
                'policy_type', policy_type, 'str')
        response = self._send(
            http_method='GET',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='5.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[PolicyConfiguration]',
                                 self._unwrap_collection(response))

    def update_policy_configuration(self, configuration, project,
                                    configuration_id):
        """UpdatePolicyConfiguration.
        Update a policy configuration by its ID.
        :param :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>` configuration: The policy configuration to update.
        :param str project: Project ID or project name
        :param int configuration_id: ID of the existing policy configuration to be updated.
        :rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        content = self._serialize.body(configuration, 'PolicyConfiguration')
        response = self._send(
            http_method='PUT',
            location_id='dad91cbe-d183-45f8-9c6e-9c1164472121',
            version='5.1',
            route_values=route_values,
            content=content)
        return self._deserialize('PolicyConfiguration', response)

    def get_policy_configuration_revision(self, project, configuration_id,
                                          revision_id):
        """GetPolicyConfigurationRevision.
        Retrieve a specific revision of a given policy by ID.
        :param str project: Project ID or project name
        :param int configuration_id: The policy configuration ID.
        :param int revision_id: The revision ID.
        :rtype: :class:`<PolicyConfiguration> <azure.devops.v5_1.policy.models.PolicyConfiguration>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        if revision_id is not None:
            route_values['revisionId'] = self._serialize.url(
                'revision_id', revision_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='fe1e68a2-60d3-43cb-855b-85e41ae97c95',
            version='5.1',
            route_values=route_values)
        return self._deserialize('PolicyConfiguration', response)

    def get_policy_configuration_revisions(self,
                                           project,
                                           configuration_id,
                                           top=None,
                                           skip=None):
        """GetPolicyConfigurationRevisions.
        Retrieve all revisions for a given policy.
        :param str project: Project ID or project name
        :param int configuration_id: The policy configuration ID.
        :param int top: The number of revisions to retrieve.
        :param int skip: The number of revisions to ignore. For example, to retrieve results 101-150, set top to 50 and skip to 100.
        :rtype: [PolicyConfiguration]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if configuration_id is not None:
            route_values['configurationId'] = self._serialize.url(
                'configuration_id', configuration_id, 'int')
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='fe1e68a2-60d3-43cb-855b-85e41ae97c95',
            version='5.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[PolicyConfiguration]',
                                 self._unwrap_collection(response))

    def get_policy_type(self, project, type_id):
        """GetPolicyType.
        Retrieve a specific policy type by ID.
        :param str project: Project ID or project name
        :param str type_id: The policy ID.
        :rtype: :class:`<PolicyType> <azure.devops.v5_1.policy.models.PolicyType>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if type_id is not None:
            route_values['typeId'] = self._serialize.url(
                'type_id', type_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
            version='5.1',
            route_values=route_values)
        return self._deserialize('PolicyType', response)

    def get_policy_types(self, project):
        """GetPolicyTypes.
        Retrieve all available policy types.
        :param str project: Project ID or project name
        :rtype: [PolicyType]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        response = self._send(
            http_method='GET',
            location_id='44096322-2d3d-466a-bb30-d1b7de69f61f',
            version='5.1',
            route_values=route_values)
        return self._deserialize('[PolicyType]',
                                 self._unwrap_collection(response))
コード例 #30
0
class LogicManagementClient(object):
    """REST API for Azure Logic Apps.

    :ivar config: Configuration for client.
    :vartype config: LogicManagementClientConfiguration

    :ivar workflows: Workflows operations
    :vartype workflows: .operations.WorkflowsOperations
    :ivar workflow_versions: WorkflowVersions operations
    :vartype workflow_versions: .operations.WorkflowVersionsOperations
    :ivar workflow_triggers: WorkflowTriggers operations
    :vartype workflow_triggers: .operations.WorkflowTriggersOperations
    :ivar workflow_trigger_histories: WorkflowTriggerHistories operations
    :vartype workflow_trigger_histories: .operations.WorkflowTriggerHistoriesOperations
    :ivar workflow_runs: WorkflowRuns operations
    :vartype workflow_runs: .operations.WorkflowRunsOperations
    :ivar workflow_run_actions: WorkflowRunActions operations
    :vartype workflow_run_actions: .operations.WorkflowRunActionsOperations
    :ivar integration_accounts: IntegrationAccounts operations
    :vartype integration_accounts: .operations.IntegrationAccountsOperations
    :ivar schemas: Schemas operations
    :vartype schemas: .operations.SchemasOperations
    :ivar maps: Maps operations
    :vartype maps: .operations.MapsOperations
    :ivar partners: Partners operations
    :vartype partners: .operations.PartnersOperations
    :ivar agreements: Agreements operations
    :vartype agreements: .operations.AgreementsOperations
    :ivar certificates: Certificates operations
    :vartype certificates: .operations.CertificatesOperations
    :ivar sessions: Sessions operations
    :vartype sessions: .operations.SessionsOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription id.
    :type subscription_id: str
    :param str base_url: Service URL
    """
    def __init__(self, credentials, subscription_id, base_url=None):

        self.config = LogicManagementClientConfiguration(
            credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self.api_version = '2016-06-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.workflows = WorkflowsOperations(self._client, self.config,
                                             self._serialize,
                                             self._deserialize)
        self.workflow_versions = WorkflowVersionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_triggers = WorkflowTriggersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_trigger_histories = WorkflowTriggerHistoriesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.workflow_runs = WorkflowRunsOperations(self._client, self.config,
                                                    self._serialize,
                                                    self._deserialize)
        self.workflow_run_actions = WorkflowRunActionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.integration_accounts = IntegrationAccountsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.schemas = SchemasOperations(self._client, self.config,
                                         self._serialize, self._deserialize)
        self.maps = MapsOperations(self._client, self.config, self._serialize,
                                   self._deserialize)
        self.partners = PartnersOperations(self._client, self.config,
                                           self._serialize, self._deserialize)
        self.agreements = AgreementsOperations(self._client, self.config,
                                               self._serialize,
                                               self._deserialize)
        self.certificates = CertificatesOperations(self._client, self.config,
                                                   self._serialize,
                                                   self._deserialize)
        self.sessions = SessionsOperations(self._client, self.config,
                                           self._serialize, self._deserialize)

    def list_operations(self,
                        custom_headers=None,
                        raw=False,
                        **operation_config):
        """Lists all of the available Logic REST API operations.

        :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>`.
        :rtype: :class:`OperationPaged
         <azure.mgmt.logic.models.OperationPaged>`
        :raises:
         :class:`ErrorResponseException<azure.mgmt.logic.models.ErrorResponseException>`
        """
        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Logic/operations'

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query(
                    "self.config.api_version", self.config.api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(request, header_parameters,
                                         **operation_config)

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

            return response

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

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

        return deserialized
コード例 #31
0
class TaskAgentClient(VssClient):
    """TaskAgent
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(TaskAgentClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = 'a85b8835-c1a1-4aac-ae97-1c3d0ba72dbd'

    def add_deployment_group(self, deployment_group, project):
        """AddDeploymentGroup.
        [Preview API] Create a deployment group.
        :param :class:`<DeploymentGroupCreateParameter> <task-agent.v4_1.models.DeploymentGroupCreateParameter>` deployment_group: Deployment group to create.
        :param str project: Project ID or project name
        :rtype: :class:`<DeploymentGroup> <task-agent.v4_1.models.DeploymentGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(deployment_group,
                                       'DeploymentGroupCreateParameter')
        response = self._send(
            http_method='POST',
            location_id='083c4d89-ab35-45af-aa11-7cf66895c53e',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('DeploymentGroup', response)

    def delete_deployment_group(self, project, deployment_group_id):
        """DeleteDeploymentGroup.
        [Preview API] Delete a deployment group.
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group to be deleted.
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        self._send(http_method='DELETE',
                   location_id='083c4d89-ab35-45af-aa11-7cf66895c53e',
                   version='4.1-preview.1',
                   route_values=route_values)

    def get_deployment_group(self,
                             project,
                             deployment_group_id,
                             action_filter=None,
                             expand=None):
        """GetDeploymentGroup.
        [Preview API] Get a deployment group by its ID.
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group.
        :param str action_filter: Get the deployment group only if this action can be performed on it.
        :param str expand: Include these additional details in the returned object.
        :rtype: :class:`<DeploymentGroup> <task-agent.v4_1.models.DeploymentGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        query_parameters = {}
        if action_filter is not None:
            query_parameters['actionFilter'] = self._serialize.query(
                'action_filter', action_filter, 'str')
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query(
                'expand', expand, 'str')
        response = self._send(
            http_method='GET',
            location_id='083c4d89-ab35-45af-aa11-7cf66895c53e',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('DeploymentGroup', response)

    def get_deployment_groups(self,
                              project,
                              name=None,
                              action_filter=None,
                              expand=None,
                              continuation_token=None,
                              top=None,
                              ids=None):
        """GetDeploymentGroups.
        [Preview API] Get a list of deployment groups by name or IDs.
        :param str project: Project ID or project name
        :param str name: Name of the deployment group.
        :param str action_filter: Get only deployment groups on which this action can be performed.
        :param str expand: Include these additional details in the returned objects.
        :param str continuation_token: Get deployment groups with names greater than this continuationToken lexicographically.
        :param int top: Maximum number of deployment groups to return. Default is **1000**.
        :param [int] ids: Comma separated list of IDs of the deployment groups.
        :rtype: [DeploymentGroup]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if name is not None:
            query_parameters['name'] = self._serialize.query(
                'name', name, 'str')
        if action_filter is not None:
            query_parameters['actionFilter'] = self._serialize.query(
                'action_filter', action_filter, 'str')
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query(
                'expand', expand, 'str')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'str')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if ids is not None:
            ids = ",".join(map(str, ids))
            query_parameters['ids'] = self._serialize.query('ids', ids, 'str')
        response = self._send(
            http_method='GET',
            location_id='083c4d89-ab35-45af-aa11-7cf66895c53e',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[DeploymentGroup]',
                                 self._unwrap_collection(response))

    def update_deployment_group(self, deployment_group, project,
                                deployment_group_id):
        """UpdateDeploymentGroup.
        [Preview API] Update a deployment group.
        :param :class:`<DeploymentGroupUpdateParameter> <task-agent.v4_1.models.DeploymentGroupUpdateParameter>` deployment_group: Deployment group to update.
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group.
        :rtype: :class:`<DeploymentGroup> <task-agent.v4_1.models.DeploymentGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        content = self._serialize.body(deployment_group,
                                       'DeploymentGroupUpdateParameter')
        response = self._send(
            http_method='PATCH',
            location_id='083c4d89-ab35-45af-aa11-7cf66895c53e',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('DeploymentGroup', response)

    def delete_deployment_target(self, project, deployment_group_id,
                                 target_id):
        """DeleteDeploymentTarget.
        [Preview API] Delete a deployment target in a deployment group. This deletes the agent from associated deployment pool too.
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group in which deployment target is deleted.
        :param int target_id: ID of the deployment target to delete.
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        if target_id is not None:
            route_values['targetId'] = self._serialize.url(
                'target_id', target_id, 'int')
        self._send(http_method='DELETE',
                   location_id='2f0aa599-c121-4256-a5fd-ba370e0ae7b6',
                   version='4.1-preview.1',
                   route_values=route_values)

    def get_deployment_target(self,
                              project,
                              deployment_group_id,
                              target_id,
                              expand=None):
        """GetDeploymentTarget.
        [Preview API] Get a deployment target by its ID in a deployment group
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group to which deployment target belongs.
        :param int target_id: ID of the deployment target to return.
        :param str expand: Include these additional details in the returned objects.
        :rtype: :class:`<DeploymentMachine> <task-agent.v4_1.models.DeploymentMachine>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        if target_id is not None:
            route_values['targetId'] = self._serialize.url(
                'target_id', target_id, 'int')
        query_parameters = {}
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query(
                'expand', expand, 'str')
        response = self._send(
            http_method='GET',
            location_id='2f0aa599-c121-4256-a5fd-ba370e0ae7b6',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('DeploymentMachine', response)

    def get_deployment_targets(self,
                               project,
                               deployment_group_id,
                               tags=None,
                               name=None,
                               partial_name_match=None,
                               expand=None,
                               agent_status=None,
                               agent_job_result=None,
                               continuation_token=None,
                               top=None):
        """GetDeploymentTargets.
        [Preview API] Get a list of deployment targets in a deployment group.
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group.
        :param [str] tags: Get only the deployment targets that contain all these comma separted list of tags.
        :param str name: Name pattern of the deployment targets to return.
        :param bool partial_name_match: When set to true, treats **name** as pattern. Else treats it as absolute match. Default is **false**.
        :param str expand: Include these additional details in the returned objects.
        :param str agent_status: Get only deployment targets that have this status.
        :param str agent_job_result: Get only deployment targets that have this last job result.
        :param str continuation_token: Get deployment targets with names greater than this continuationToken lexicographically.
        :param int top: Maximum number of deployment targets to return. Default is **1000**.
        :rtype: [DeploymentMachine]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        query_parameters = {}
        if tags is not None:
            tags = ",".join(tags)
            query_parameters['tags'] = self._serialize.query(
                'tags', tags, 'str')
        if name is not None:
            query_parameters['name'] = self._serialize.query(
                'name', name, 'str')
        if partial_name_match is not None:
            query_parameters['partialNameMatch'] = self._serialize.query(
                'partial_name_match', partial_name_match, 'bool')
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query(
                'expand', expand, 'str')
        if agent_status is not None:
            query_parameters['agentStatus'] = self._serialize.query(
                'agent_status', agent_status, 'str')
        if agent_job_result is not None:
            query_parameters['agentJobResult'] = self._serialize.query(
                'agent_job_result', agent_job_result, 'str')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'str')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        response = self._send(
            http_method='GET',
            location_id='2f0aa599-c121-4256-a5fd-ba370e0ae7b6',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[DeploymentMachine]',
                                 self._unwrap_collection(response))

    def update_deployment_targets(self, machines, project,
                                  deployment_group_id):
        """UpdateDeploymentTargets.
        [Preview API] Update tags of a list of deployment targets in a deployment group.
        :param [DeploymentTargetUpdateParameter] machines: Deployment targets with tags to udpdate.
        :param str project: Project ID or project name
        :param int deployment_group_id: ID of the deployment group in which deployment targets are updated.
        :rtype: [DeploymentMachine]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if deployment_group_id is not None:
            route_values['deploymentGroupId'] = self._serialize.url(
                'deployment_group_id', deployment_group_id, 'int')
        content = self._serialize.body(machines,
                                       '[DeploymentTargetUpdateParameter]')
        response = self._send(
            http_method='PATCH',
            location_id='2f0aa599-c121-4256-a5fd-ba370e0ae7b6',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[DeploymentMachine]',
                                 self._unwrap_collection(response))

    def add_task_group(self, task_group, project):
        """AddTaskGroup.
        [Preview API] Create a task group.
        :param :class:`<TaskGroupCreateParameter> <task-agent.v4_1.models.TaskGroupCreateParameter>` task_group: Task group object to create.
        :param str project: Project ID or project name
        :rtype: :class:`<TaskGroup> <task-agent.v4_1.models.TaskGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(task_group, 'TaskGroupCreateParameter')
        response = self._send(
            http_method='POST',
            location_id='6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('TaskGroup', response)

    def delete_task_group(self, project, task_group_id, comment=None):
        """DeleteTaskGroup.
        [Preview API] Delete a task group.
        :param str project: Project ID or project name
        :param str task_group_id: Id of the task group to be deleted.
        :param str comment: Comments to delete.
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if task_group_id is not None:
            route_values['taskGroupId'] = self._serialize.url(
                'task_group_id', task_group_id, 'str')
        query_parameters = {}
        if comment is not None:
            query_parameters['comment'] = self._serialize.query(
                'comment', comment, 'str')
        self._send(http_method='DELETE',
                   location_id='6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7',
                   version='4.1-preview.1',
                   route_values=route_values,
                   query_parameters=query_parameters)

    def get_task_groups(self,
                        project,
                        task_group_id=None,
                        expanded=None,
                        task_id_filter=None,
                        deleted=None,
                        top=None,
                        continuation_token=None,
                        query_order=None):
        """GetTaskGroups.
        [Preview API] List task groups.
        :param str project: Project ID or project name
        :param str task_group_id: Id of the task group.
        :param bool expanded: 'true' to recursively expand task groups. Default is 'false'.
        :param str task_id_filter: Guid of the taskId to filter.
        :param bool deleted: 'true'to include deleted task groups. Default is 'false'.
        :param int top: Number of task groups to get.
        :param datetime continuation_token: Gets the task groups after the continuation token provided.
        :param str query_order: Gets the results in the defined order. Default is 'CreatedOnDescending'.
        :rtype: [TaskGroup]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if task_group_id is not None:
            route_values['taskGroupId'] = self._serialize.url(
                'task_group_id', task_group_id, 'str')
        query_parameters = {}
        if expanded is not None:
            query_parameters['expanded'] = self._serialize.query(
                'expanded', expanded, 'bool')
        if task_id_filter is not None:
            query_parameters['taskIdFilter'] = self._serialize.query(
                'task_id_filter', task_id_filter, 'str')
        if deleted is not None:
            query_parameters['deleted'] = self._serialize.query(
                'deleted', deleted, 'bool')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'iso-8601')
        if query_order is not None:
            query_parameters['queryOrder'] = self._serialize.query(
                'query_order', query_order, 'str')
        response = self._send(
            http_method='GET',
            location_id='6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TaskGroup]',
                                 self._unwrap_collection(response))

    def update_task_group(self, task_group, project, task_group_id=None):
        """UpdateTaskGroup.
        [Preview API] Update a task group.
        :param :class:`<TaskGroupUpdateParameter> <task-agent.v4_1.models.TaskGroupUpdateParameter>` task_group: Task group to update.
        :param str project: Project ID or project name
        :param str task_group_id: Id of the task group to update.
        :rtype: :class:`<TaskGroup> <task-agent.v4_1.models.TaskGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if task_group_id is not None:
            route_values['taskGroupId'] = self._serialize.url(
                'task_group_id', task_group_id, 'str')
        content = self._serialize.body(task_group, 'TaskGroupUpdateParameter')
        response = self._send(
            http_method='PUT',
            location_id='6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('TaskGroup', response)

    def add_variable_group(self, group, project):
        """AddVariableGroup.
        [Preview API] Add a variable group.
        :param :class:`<VariableGroupParameters> <task-agent.v4_1.models.VariableGroupParameters>` group: Variable group to add.
        :param str project: Project ID or project name
        :rtype: :class:`<VariableGroup> <task-agent.v4_1.models.VariableGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(group, 'VariableGroupParameters')
        response = self._send(
            http_method='POST',
            location_id='f5b09dd5-9d54-45a1-8b5a-1c8287d634cc',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('VariableGroup', response)

    def delete_variable_group(self, project, group_id):
        """DeleteVariableGroup.
        [Preview API] Delete a variable group
        :param str project: Project ID or project name
        :param int group_id: Id of the variable group.
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'int')
        self._send(http_method='DELETE',
                   location_id='f5b09dd5-9d54-45a1-8b5a-1c8287d634cc',
                   version='4.1-preview.1',
                   route_values=route_values)

    def get_variable_group(self, project, group_id):
        """GetVariableGroup.
        [Preview API] Get a variable group.
        :param str project: Project ID or project name
        :param int group_id: Id of the variable group.
        :rtype: :class:`<VariableGroup> <task-agent.v4_1.models.VariableGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='f5b09dd5-9d54-45a1-8b5a-1c8287d634cc',
            version='4.1-preview.1',
            route_values=route_values)
        return self._deserialize('VariableGroup', response)

    def get_variable_groups(self,
                            project,
                            group_name=None,
                            action_filter=None,
                            top=None,
                            continuation_token=None,
                            query_order=None):
        """GetVariableGroups.
        [Preview API] Get variable groups.
        :param str project: Project ID or project name
        :param str group_name: Name of variable group.
        :param str action_filter: Action filter for the variable group. It specifies the action which can be performed on the variable groups.
        :param int top: Number of variable groups to get.
        :param int continuation_token: Gets the variable groups after the continuation token provided.
        :param str query_order: Gets the results in the defined order. Default is 'IdDescending'.
        :rtype: [VariableGroup]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if group_name is not None:
            query_parameters['groupName'] = self._serialize.query(
                'group_name', group_name, 'str')
        if action_filter is not None:
            query_parameters['actionFilter'] = self._serialize.query(
                'action_filter', action_filter, 'str')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'int')
        if query_order is not None:
            query_parameters['queryOrder'] = self._serialize.query(
                'query_order', query_order, 'str')
        response = self._send(
            http_method='GET',
            location_id='f5b09dd5-9d54-45a1-8b5a-1c8287d634cc',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[VariableGroup]',
                                 self._unwrap_collection(response))

    def get_variable_groups_by_id(self, project, group_ids):
        """GetVariableGroupsById.
        [Preview API] Get variable groups by ids.
        :param str project: Project ID or project name
        :param [int] group_ids: Comma separated list of Ids of variable groups.
        :rtype: [VariableGroup]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if group_ids is not None:
            group_ids = ",".join(map(str, group_ids))
            query_parameters['groupIds'] = self._serialize.query(
                'group_ids', group_ids, 'str')
        response = self._send(
            http_method='GET',
            location_id='f5b09dd5-9d54-45a1-8b5a-1c8287d634cc',
            version='4.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[VariableGroup]',
                                 self._unwrap_collection(response))

    def update_variable_group(self, group, project, group_id):
        """UpdateVariableGroup.
        [Preview API] Update a variable group.
        :param :class:`<VariableGroupParameters> <task-agent.v4_1.models.VariableGroupParameters>` group: Variable group to update.
        :param str project: Project ID or project name
        :param int group_id: Id of the variable group to update.
        :rtype: :class:`<VariableGroup> <task-agent.v4_1.models.VariableGroup>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'int')
        content = self._serialize.body(group, 'VariableGroupParameters')
        response = self._send(
            http_method='PUT',
            location_id='f5b09dd5-9d54-45a1-8b5a-1c8287d634cc',
            version='4.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('VariableGroup', response)
コード例 #32
0
class PipelinesClient(Client):
    """Pipelines
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(PipelinesClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def create_pipeline(self, input_parameters, project):
        """CreatePipeline.
        [Preview API]
        :param :class:`<CreatePipelineParameters> <azure.devops.v5_1.pipelines.models.CreatePipelineParameters>` input_parameters:
        :param str project: Project ID or project name
        :rtype: :class:`<Pipeline> <azure.devops.v5_1.pipelines.models.Pipeline>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        content = self._serialize.body(input_parameters,
                                       'CreatePipelineParameters')
        response = self._send(
            http_method='POST',
            location_id='28e1305e-2afe-47bf-abaf-cbb0e6a91988',
            version='5.1-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Pipeline', response)

    def get_pipeline(self, project, pipeline_id, pipeline_version=None):
        """GetPipeline.
        [Preview API] Gets a pipeline, optionally at the specified version
        :param str project: Project ID or project name
        :param int pipeline_id: The pipeline id
        :param int pipeline_version: The pipeline version
        :rtype: :class:`<Pipeline> <azure.devops.v5_1.pipelines.models.Pipeline>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if pipeline_id is not None:
            route_values['pipelineId'] = self._serialize.url(
                'pipeline_id', pipeline_id, 'int')
        query_parameters = {}
        if pipeline_version is not None:
            query_parameters['pipelineVersion'] = self._serialize.query(
                'pipeline_version', pipeline_version, 'int')
        response = self._send(
            http_method='GET',
            location_id='28e1305e-2afe-47bf-abaf-cbb0e6a91988',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('Pipeline', response)

    def list_pipelines(self,
                       project,
                       order_by=None,
                       top=None,
                       continuation_token=None):
        """ListPipelines.
        [Preview API] Gets a list of pipelines.
        :param str project: Project ID or project name
        :param str order_by: A sort expression. Defaults to "name asc"
        :param int top: The maximum number of pipelines to return
        :param str continuation_token: A continuation token from a previous request, to retrieve the next page of results
        :rtype: [Pipeline]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        query_parameters = {}
        if order_by is not None:
            query_parameters['orderBy'] = self._serialize.query(
                'order_by', order_by, 'str')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'str')
        response = self._send(
            http_method='GET',
            location_id='28e1305e-2afe-47bf-abaf-cbb0e6a91988',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[Pipeline]',
                                 self._unwrap_collection(response))

    def get_run(self, project, pipeline_id, run_id):
        """GetRun.
        [Preview API] Gets a run for a particular pipeline.
        :param str project: Project ID or project name
        :param int pipeline_id: The pipeline id
        :param int run_id: The run id
        :rtype: :class:`<Run> <azure.devops.v5_1.pipelines.models.Run>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if pipeline_id is not None:
            route_values['pipelineId'] = self._serialize.url(
                'pipeline_id', pipeline_id, 'int')
        if run_id is not None:
            route_values['runId'] = self._serialize.url(
                'run_id', run_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='7859261e-d2e9-4a68-b820-a5d84cc5bb3d',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('Run', response)

    def list_runs(self, project, pipeline_id):
        """ListRuns.
        [Preview API] Gets top 10000 runs for a particular pipeline.
        :param str project: Project ID or project name
        :param int pipeline_id: The pipeline id
        :rtype: [Run]
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if pipeline_id is not None:
            route_values['pipelineId'] = self._serialize.url(
                'pipeline_id', pipeline_id, 'int')
        response = self._send(
            http_method='GET',
            location_id='7859261e-d2e9-4a68-b820-a5d84cc5bb3d',
            version='5.1-preview.1',
            route_values=route_values)
        return self._deserialize('[Run]', self._unwrap_collection(response))

    def run_pipeline(self,
                     run_parameters,
                     project,
                     pipeline_id,
                     pipeline_version=None):
        """RunPipeline.
        [Preview API] Runs a pipeline.
        :param :class:`<RunPipelineParameters> <azure.devops.v5_1.pipelines.models.RunPipelineParameters>` run_parameters: Optional.
        :param str project: Project ID or project name
        :param int pipeline_id: The pipeline id
        :param int pipeline_version: The pipeline version
        :rtype: :class:`<Run> <azure.devops.v5_1.pipelines.models.Run>`
        """
        route_values = {}
        if project is not None:
            route_values['project'] = self._serialize.url(
                'project', project, 'str')
        if pipeline_id is not None:
            route_values['pipelineId'] = self._serialize.url(
                'pipeline_id', pipeline_id, 'int')
        query_parameters = {}
        if pipeline_version is not None:
            query_parameters['pipelineVersion'] = self._serialize.query(
                'pipeline_version', pipeline_version, 'int')
        content = self._serialize.body(run_parameters, 'RunPipelineParameters')
        response = self._send(
            http_method='POST',
            location_id='7859261e-d2e9-4a68-b820-a5d84cc5bb3d',
            version='5.1-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('Run', response)
コード例 #33
0
class CoreClient(VssClient):
    """Core
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(CoreClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '79134c72-4a58-4b42-976c-04e7115f32bf'

    def create_connected_service(self, connected_service_creation_data,
                                 project_id):
        """CreateConnectedService.
        [Preview API]
        :param :class:`<WebApiConnectedServiceDetails> <core.v4_0.models.WebApiConnectedServiceDetails>` connected_service_creation_data:
        :param str project_id:
        :rtype: :class:`<WebApiConnectedService> <core.v4_0.models.WebApiConnectedService>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(connected_service_creation_data,
                                       'WebApiConnectedServiceDetails')
        response = self._send(
            http_method='POST',
            location_id='b4f70219-e18b-42c5-abe3-98b07d35525e',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WebApiConnectedService', response)

    def get_connected_service_details(self, project_id, name):
        """GetConnectedServiceDetails.
        [Preview API]
        :param str project_id:
        :param str name:
        :rtype: :class:`<WebApiConnectedServiceDetails> <core.v4_0.models.WebApiConnectedServiceDetails>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if name is not None:
            route_values['name'] = self._serialize.url('name', name, 'str')
        response = self._send(
            http_method='GET',
            location_id='b4f70219-e18b-42c5-abe3-98b07d35525e',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('WebApiConnectedServiceDetails', response)

    def get_connected_services(self, project_id, kind=None):
        """GetConnectedServices.
        [Preview API]
        :param str project_id:
        :param ConnectedServiceKind kind:
        :rtype: [WebApiConnectedService]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if kind is not None:
            query_parameters['kind'] = self._serialize.query(
                'kind', kind, 'ConnectedServiceKind')
        response = self._send(
            http_method='GET',
            location_id='b4f70219-e18b-42c5-abe3-98b07d35525e',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[WebApiConnectedService]', response)

    def create_identity_mru(self, mru_data, mru_name):
        """CreateIdentityMru.
        [Preview API]
        :param :class:`<IdentityData> <core.v4_0.models.IdentityData>` mru_data:
        :param str mru_name:
        """
        route_values = {}
        if mru_name is not None:
            route_values['mruName'] = self._serialize.url(
                'mru_name', mru_name, 'str')
        content = self._serialize.body(mru_data, 'IdentityData')
        self._send(http_method='POST',
                   location_id='5ead0b70-2572-4697-97e9-f341069a783a',
                   version='4.0-preview.1',
                   route_values=route_values,
                   content=content)

    def get_identity_mru(self, mru_name):
        """GetIdentityMru.
        [Preview API]
        :param str mru_name:
        :rtype: [IdentityRef]
        """
        route_values = {}
        if mru_name is not None:
            route_values['mruName'] = self._serialize.url(
                'mru_name', mru_name, 'str')
        response = self._send(
            http_method='GET',
            location_id='5ead0b70-2572-4697-97e9-f341069a783a',
            version='4.0-preview.1',
            route_values=route_values,
            returns_collection=True)
        return self._deserialize('[IdentityRef]', response)

    def update_identity_mru(self, mru_data, mru_name):
        """UpdateIdentityMru.
        [Preview API]
        :param :class:`<IdentityData> <core.v4_0.models.IdentityData>` mru_data:
        :param str mru_name:
        """
        route_values = {}
        if mru_name is not None:
            route_values['mruName'] = self._serialize.url(
                'mru_name', mru_name, 'str')
        content = self._serialize.body(mru_data, 'IdentityData')
        self._send(http_method='PATCH',
                   location_id='5ead0b70-2572-4697-97e9-f341069a783a',
                   version='4.0-preview.1',
                   route_values=route_values,
                   content=content)

    def get_team_members(self, project_id, team_id, top=None, skip=None):
        """GetTeamMembers.
        :param str project_id:
        :param str team_id:
        :param int top:
        :param int skip:
        :rtype: [IdentityRef]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='294c494c-2600-4d7e-b76c-3dd50c3c95be',
            version='4.0',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[IdentityRef]', response)

    def get_process_by_id(self, process_id):
        """GetProcessById.
        Retrieve process by id
        :param str process_id:
        :rtype: :class:`<Process> <core.v4_0.models.Process>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='93878975-88c5-4e6a-8abb-7ddd77a8a7d8',
            version='4.0',
            route_values=route_values)
        return self._deserialize('Process', response)

    def get_processes(self):
        """GetProcesses.
        Retrieve all processes
        :rtype: [Process]
        """
        response = self._send(
            http_method='GET',
            location_id='93878975-88c5-4e6a-8abb-7ddd77a8a7d8',
            version='4.0',
            returns_collection=True)
        return self._deserialize('[Process]', response)

    def get_project_collection(self, collection_id):
        """GetProjectCollection.
        Get project collection with the specified id or name.
        :param str collection_id:
        :rtype: :class:`<TeamProjectCollection> <core.v4_0.models.TeamProjectCollection>`
        """
        route_values = {}
        if collection_id is not None:
            route_values['collectionId'] = self._serialize.url(
                'collection_id', collection_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='8031090f-ef1d-4af6-85fc-698cd75d42bf',
            version='4.0',
            route_values=route_values)
        return self._deserialize('TeamProjectCollection', response)

    def get_project_collections(self, top=None, skip=None):
        """GetProjectCollections.
        Get project collection references for this application.
        :param int top:
        :param int skip:
        :rtype: [TeamProjectCollectionReference]
        """
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='8031090f-ef1d-4af6-85fc-698cd75d42bf',
            version='4.0',
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[TeamProjectCollectionReference]', response)

    def get_project_history_entries(self, min_revision=None):
        """GetProjectHistoryEntries.
        [Preview API]
        :param long min_revision:
        :rtype: [ProjectInfo]
        """
        query_parameters = {}
        if min_revision is not None:
            query_parameters['minRevision'] = self._serialize.query(
                'min_revision', min_revision, 'long')
        response = self._send(
            http_method='GET',
            location_id='6488a877-4749-4954-82ea-7340d36be9f2',
            version='4.0-preview.2',
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[ProjectInfo]', response)

    def get_project(self,
                    project_id,
                    include_capabilities=None,
                    include_history=None):
        """GetProject.
        Get project with the specified id or name, optionally including capabilities.
        :param str project_id:
        :param bool include_capabilities: Include capabilities (such as source control) in the team project result (default: false).
        :param bool include_history: Search within renamed projects (that had such name in the past).
        :rtype: :class:`<TeamProject> <core.v4_0.models.TeamProject>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if include_capabilities is not None:
            query_parameters['includeCapabilities'] = self._serialize.query(
                'include_capabilities', include_capabilities, 'bool')
        if include_history is not None:
            query_parameters['includeHistory'] = self._serialize.query(
                'include_history', include_history, 'bool')
        response = self._send(
            http_method='GET',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='4.0',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('TeamProject', response)

    def get_projects(self,
                     state_filter=None,
                     top=None,
                     skip=None,
                     continuation_token=None):
        """GetProjects.
        Get project references with the specified state
        :param object state_filter: Filter on team projects in a specific team project state (default: WellFormed).
        :param int top:
        :param int skip:
        :param str continuation_token:
        :rtype: [TeamProjectReference]
        """
        query_parameters = {}
        if state_filter is not None:
            query_parameters['stateFilter'] = self._serialize.query(
                'state_filter', state_filter, 'object')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'str')
        response = self._send(
            http_method='GET',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='4.0',
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[TeamProjectReference]', response)

    def queue_create_project(self, project_to_create):
        """QueueCreateProject.
        Queue a project creation.
        :param :class:`<TeamProject> <core.v4_0.models.TeamProject>` project_to_create: The project to create.
        :rtype: :class:`<OperationReference> <core.v4_0.models.OperationReference>`
        """
        content = self._serialize.body(project_to_create, 'TeamProject')
        response = self._send(
            http_method='POST',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='4.0',
            content=content)
        return self._deserialize('OperationReference', response)

    def queue_delete_project(self, project_id):
        """QueueDeleteProject.
        Queue a project deletion.
        :param str project_id: The project id of the project to delete.
        :rtype: :class:`<OperationReference> <core.v4_0.models.OperationReference>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        response = self._send(
            http_method='DELETE',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='4.0',
            route_values=route_values)
        return self._deserialize('OperationReference', response)

    def update_project(self, project_update, project_id):
        """UpdateProject.
        Update an existing project's name, abbreviation, or description.
        :param :class:`<TeamProject> <core.v4_0.models.TeamProject>` project_update: The updates for the project.
        :param str project_id: The project id of the project to update.
        :rtype: :class:`<OperationReference> <core.v4_0.models.OperationReference>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(project_update, 'TeamProject')
        response = self._send(
            http_method='PATCH',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='4.0',
            route_values=route_values,
            content=content)
        return self._deserialize('OperationReference', response)

    def get_project_properties(self, project_id, keys=None):
        """GetProjectProperties.
        [Preview API] Get a collection of team project properties.
        :param str project_id: The team project ID.
        :param [str] keys: A comma-delimited string of team project property names. Wildcard characters ("?" and "*") are supported. If no key is specified, all properties will be returned.
        :rtype: [ProjectProperty]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if keys is not None:
            keys = ",".join(keys)
            query_parameters['keys'] = self._serialize.query(
                'keys', keys, 'str')
        response = self._send(
            http_method='GET',
            location_id='4976a71a-4487-49aa-8aab-a1eda469037a',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[ProjectProperty]', response)

    def set_project_properties(self, project_id, patch_document):
        """SetProjectProperties.
        [Preview API] Create, update, and delete team project properties.
        :param str project_id: The team project ID.
        :param :class:`<[JsonPatchOperation]> <core.v4_0.models.[JsonPatchOperation]>` patch_document: A JSON Patch document that represents an array of property operations. See RFC 6902 for more details on JSON Patch. The accepted operation verbs are Add and Remove, where Add is used for both creating and updating properties. The path consists of a forward slash and a property name.
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(patch_document, '[JsonPatchOperation]')
        self._send(http_method='PATCH',
                   location_id='4976a71a-4487-49aa-8aab-a1eda469037a',
                   version='4.0-preview.1',
                   route_values=route_values,
                   content=content,
                   media_type='application/json-patch+json')

    def create_or_update_proxy(self, proxy):
        """CreateOrUpdateProxy.
        [Preview API]
        :param :class:`<Proxy> <core.v4_0.models.Proxy>` proxy:
        :rtype: :class:`<Proxy> <core.v4_0.models.Proxy>`
        """
        content = self._serialize.body(proxy, 'Proxy')
        response = self._send(
            http_method='PUT',
            location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
            version='4.0-preview.2',
            content=content)
        return self._deserialize('Proxy', response)

    def delete_proxy(self, proxy_url, site=None):
        """DeleteProxy.
        [Preview API]
        :param str proxy_url:
        :param str site:
        """
        query_parameters = {}
        if proxy_url is not None:
            query_parameters['proxyUrl'] = self._serialize.query(
                'proxy_url', proxy_url, 'str')
        if site is not None:
            query_parameters['site'] = self._serialize.query(
                'site', site, 'str')
        self._send(http_method='DELETE',
                   location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
                   version='4.0-preview.2',
                   query_parameters=query_parameters)

    def get_proxies(self, proxy_url=None):
        """GetProxies.
        [Preview API]
        :param str proxy_url:
        :rtype: [Proxy]
        """
        query_parameters = {}
        if proxy_url is not None:
            query_parameters['proxyUrl'] = self._serialize.query(
                'proxy_url', proxy_url, 'str')
        response = self._send(
            http_method='GET',
            location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
            version='4.0-preview.2',
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[Proxy]', response)

    def create_team(self, team, project_id):
        """CreateTeam.
        Creates a team
        :param :class:`<WebApiTeam> <core.v4_0.models.WebApiTeam>` team: The team data used to create the team.
        :param str project_id: The name or id (GUID) of the team project in which to create the team.
        :rtype: :class:`<WebApiTeam> <core.v4_0.models.WebApiTeam>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(team, 'WebApiTeam')
        response = self._send(
            http_method='POST',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='4.0',
            route_values=route_values,
            content=content)
        return self._deserialize('WebApiTeam', response)

    def delete_team(self, project_id, team_id):
        """DeleteTeam.
        Deletes a team
        :param str project_id: The name or id (GUID) of the team project containing the team to delete.
        :param str team_id: The name of id of the team to delete.
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        self._send(http_method='DELETE',
                   location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
                   version='4.0',
                   route_values=route_values)

    def get_team(self, project_id, team_id):
        """GetTeam.
        Gets a team
        :param str project_id:
        :param str team_id:
        :rtype: :class:`<WebApiTeam> <core.v4_0.models.WebApiTeam>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='4.0',
            route_values=route_values)
        return self._deserialize('WebApiTeam', response)

    def get_teams(self, project_id, top=None, skip=None):
        """GetTeams.
        :param str project_id:
        :param int top:
        :param int skip:
        :rtype: [WebApiTeam]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='4.0',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[WebApiTeam]', response)

    def update_team(self, team_data, project_id, team_id):
        """UpdateTeam.
        Updates a team's name and/or description
        :param :class:`<WebApiTeam> <core.v4_0.models.WebApiTeam>` team_data:
        :param str project_id: The name or id (GUID) of the team project containing the team to update.
        :param str team_id: The name of id of the team to update.
        :rtype: :class:`<WebApiTeam> <core.v4_0.models.WebApiTeam>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        content = self._serialize.body(team_data, 'WebApiTeam')
        response = self._send(
            http_method='PATCH',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='4.0',
            route_values=route_values,
            content=content)
        return self._deserialize('WebApiTeam', response)
コード例 #34
0
class WorkItemTrackingClient(VssClient):
    """WorkItemTracking
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(WorkItemTrackingClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def create_behavior(self, behavior, process_id):
        """CreateBehavior.
        [Preview API]
        :param :class:`<BehaviorCreateModel> <work-item-tracking.v4_0.models.BehaviorCreateModel>` behavior:
        :param str process_id:
        :rtype: :class:`<BehaviorModel> <work-item-tracking.v4_0.models.BehaviorModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        content = self._serialize.body(behavior, 'BehaviorCreateModel')
        response = self._send(
            http_method='POST',
            location_id='47a651f4-fb70-43bf-b96b-7c0ba947142b',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('BehaviorModel', response)

    def delete_behavior(self, process_id, behavior_id):
        """DeleteBehavior.
        [Preview API]
        :param str process_id:
        :param str behavior_id:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if behavior_id is not None:
            route_values['behaviorId'] = self._serialize.url(
                'behavior_id', behavior_id, 'str')
        self._send(http_method='DELETE',
                   location_id='47a651f4-fb70-43bf-b96b-7c0ba947142b',
                   version='4.0-preview.1',
                   route_values=route_values)

    def get_behavior(self, process_id, behavior_id):
        """GetBehavior.
        [Preview API]
        :param str process_id:
        :param str behavior_id:
        :rtype: :class:`<BehaviorModel> <work-item-tracking.v4_0.models.BehaviorModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if behavior_id is not None:
            route_values['behaviorId'] = self._serialize.url(
                'behavior_id', behavior_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='47a651f4-fb70-43bf-b96b-7c0ba947142b',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('BehaviorModel', response)

    def get_behaviors(self, process_id):
        """GetBehaviors.
        [Preview API]
        :param str process_id:
        :rtype: [BehaviorModel]
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='47a651f4-fb70-43bf-b96b-7c0ba947142b',
            version='4.0-preview.1',
            route_values=route_values,
            returns_collection=True)
        return self._deserialize('[BehaviorModel]', response)

    def replace_behavior(self, behavior_data, process_id, behavior_id):
        """ReplaceBehavior.
        [Preview API]
        :param :class:`<BehaviorReplaceModel> <work-item-tracking.v4_0.models.BehaviorReplaceModel>` behavior_data:
        :param str process_id:
        :param str behavior_id:
        :rtype: :class:`<BehaviorModel> <work-item-tracking.v4_0.models.BehaviorModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if behavior_id is not None:
            route_values['behaviorId'] = self._serialize.url(
                'behavior_id', behavior_id, 'str')
        content = self._serialize.body(behavior_data, 'BehaviorReplaceModel')
        response = self._send(
            http_method='PUT',
            location_id='47a651f4-fb70-43bf-b96b-7c0ba947142b',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('BehaviorModel', response)

    def add_control_to_group(self, control, process_id, wit_ref_name,
                             group_id):
        """AddControlToGroup.
        [Preview API] Creates a control, giving it an id, and adds it to the group. So far, the only controls that don't know how to generate their own ids are control extensions.
        :param :class:`<Control> <work-item-tracking.v4_0.models.Control>` control:
        :param str process_id:
        :param str wit_ref_name:
        :param str group_id:
        :rtype: :class:`<Control> <work-item-tracking.v4_0.models.Control>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        content = self._serialize.body(control, 'Control')
        response = self._send(
            http_method='POST',
            location_id='e2e3166a-627a-4e9b-85b2-d6a097bbd731',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Control', response)

    def edit_control(self, control, process_id, wit_ref_name, group_id,
                     control_id):
        """EditControl.
        [Preview API]
        :param :class:`<Control> <work-item-tracking.v4_0.models.Control>` control:
        :param str process_id:
        :param str wit_ref_name:
        :param str group_id:
        :param str control_id:
        :rtype: :class:`<Control> <work-item-tracking.v4_0.models.Control>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        if control_id is not None:
            route_values['controlId'] = self._serialize.url(
                'control_id', control_id, 'str')
        content = self._serialize.body(control, 'Control')
        response = self._send(
            http_method='PATCH',
            location_id='e2e3166a-627a-4e9b-85b2-d6a097bbd731',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Control', response)

    def remove_control_from_group(self, process_id, wit_ref_name, group_id,
                                  control_id):
        """RemoveControlFromGroup.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :param str group_id:
        :param str control_id:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        if control_id is not None:
            route_values['controlId'] = self._serialize.url(
                'control_id', control_id, 'str')
        self._send(http_method='DELETE',
                   location_id='e2e3166a-627a-4e9b-85b2-d6a097bbd731',
                   version='4.0-preview.1',
                   route_values=route_values)

    def set_control_in_group(self,
                             control,
                             process_id,
                             wit_ref_name,
                             group_id,
                             control_id,
                             remove_from_group_id=None):
        """SetControlInGroup.
        [Preview API] Puts a control withan id into a group. Controls backed by fields can generate their own id.
        :param :class:`<Control> <work-item-tracking.v4_0.models.Control>` control:
        :param str process_id:
        :param str wit_ref_name:
        :param str group_id:
        :param str control_id:
        :param str remove_from_group_id:
        :rtype: :class:`<Control> <work-item-tracking.v4_0.models.Control>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        if control_id is not None:
            route_values['controlId'] = self._serialize.url(
                'control_id', control_id, 'str')
        query_parameters = {}
        if remove_from_group_id is not None:
            query_parameters['removeFromGroupId'] = self._serialize.query(
                'remove_from_group_id', remove_from_group_id, 'str')
        content = self._serialize.body(control, 'Control')
        response = self._send(
            http_method='PUT',
            location_id='e2e3166a-627a-4e9b-85b2-d6a097bbd731',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('Control', response)

    def create_field(self, field, process_id):
        """CreateField.
        [Preview API]
        :param :class:`<FieldModel> <work-item-tracking.v4_0.models.FieldModel>` field:
        :param str process_id:
        :rtype: :class:`<FieldModel> <work-item-tracking.v4_0.models.FieldModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        content = self._serialize.body(field, 'FieldModel')
        response = self._send(
            http_method='POST',
            location_id='f36c66c7-911d-4163-8938-d3c5d0d7f5aa',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('FieldModel', response)

    def update_field(self, field, process_id):
        """UpdateField.
        [Preview API]
        :param :class:`<FieldUpdate> <work-item-tracking.v4_0.models.FieldUpdate>` field:
        :param str process_id:
        :rtype: :class:`<FieldModel> <work-item-tracking.v4_0.models.FieldModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        content = self._serialize.body(field, 'FieldUpdate')
        response = self._send(
            http_method='PATCH',
            location_id='f36c66c7-911d-4163-8938-d3c5d0d7f5aa',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('FieldModel', response)

    def add_group(self, group, process_id, wit_ref_name, page_id, section_id):
        """AddGroup.
        [Preview API]
        :param :class:`<Group> <work-item-tracking.v4_0.models.Group>` group:
        :param str process_id:
        :param str wit_ref_name:
        :param str page_id:
        :param str section_id:
        :rtype: :class:`<Group> <work-item-tracking.v4_0.models.Group>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if page_id is not None:
            route_values['pageId'] = self._serialize.url(
                'page_id', page_id, 'str')
        if section_id is not None:
            route_values['sectionId'] = self._serialize.url(
                'section_id', section_id, 'str')
        content = self._serialize.body(group, 'Group')
        response = self._send(
            http_method='POST',
            location_id='2617828b-e850-4375-a92a-04855704d4c3',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Group', response)

    def edit_group(self, group, process_id, wit_ref_name, page_id, section_id,
                   group_id):
        """EditGroup.
        [Preview API]
        :param :class:`<Group> <work-item-tracking.v4_0.models.Group>` group:
        :param str process_id:
        :param str wit_ref_name:
        :param str page_id:
        :param str section_id:
        :param str group_id:
        :rtype: :class:`<Group> <work-item-tracking.v4_0.models.Group>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if page_id is not None:
            route_values['pageId'] = self._serialize.url(
                'page_id', page_id, 'str')
        if section_id is not None:
            route_values['sectionId'] = self._serialize.url(
                'section_id', section_id, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        content = self._serialize.body(group, 'Group')
        response = self._send(
            http_method='PATCH',
            location_id='2617828b-e850-4375-a92a-04855704d4c3',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Group', response)

    def remove_group(self, process_id, wit_ref_name, page_id, section_id,
                     group_id):
        """RemoveGroup.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :param str page_id:
        :param str section_id:
        :param str group_id:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if page_id is not None:
            route_values['pageId'] = self._serialize.url(
                'page_id', page_id, 'str')
        if section_id is not None:
            route_values['sectionId'] = self._serialize.url(
                'section_id', section_id, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        self._send(http_method='DELETE',
                   location_id='2617828b-e850-4375-a92a-04855704d4c3',
                   version='4.0-preview.1',
                   route_values=route_values)

    def set_group_in_page(self, group, process_id, wit_ref_name, page_id,
                          section_id, group_id, remove_from_page_id,
                          remove_from_section_id):
        """SetGroupInPage.
        [Preview API]
        :param :class:`<Group> <work-item-tracking.v4_0.models.Group>` group:
        :param str process_id:
        :param str wit_ref_name:
        :param str page_id:
        :param str section_id:
        :param str group_id:
        :param str remove_from_page_id:
        :param str remove_from_section_id:
        :rtype: :class:`<Group> <work-item-tracking.v4_0.models.Group>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if page_id is not None:
            route_values['pageId'] = self._serialize.url(
                'page_id', page_id, 'str')
        if section_id is not None:
            route_values['sectionId'] = self._serialize.url(
                'section_id', section_id, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        query_parameters = {}
        if remove_from_page_id is not None:
            query_parameters['removeFromPageId'] = self._serialize.query(
                'remove_from_page_id', remove_from_page_id, 'str')
        if remove_from_section_id is not None:
            query_parameters['removeFromSectionId'] = self._serialize.query(
                'remove_from_section_id', remove_from_section_id, 'str')
        content = self._serialize.body(group, 'Group')
        response = self._send(
            http_method='PUT',
            location_id='2617828b-e850-4375-a92a-04855704d4c3',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('Group', response)

    def set_group_in_section(self, group, process_id, wit_ref_name, page_id,
                             section_id, group_id, remove_from_section_id):
        """SetGroupInSection.
        [Preview API]
        :param :class:`<Group> <work-item-tracking.v4_0.models.Group>` group:
        :param str process_id:
        :param str wit_ref_name:
        :param str page_id:
        :param str section_id:
        :param str group_id:
        :param str remove_from_section_id:
        :rtype: :class:`<Group> <work-item-tracking.v4_0.models.Group>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if page_id is not None:
            route_values['pageId'] = self._serialize.url(
                'page_id', page_id, 'str')
        if section_id is not None:
            route_values['sectionId'] = self._serialize.url(
                'section_id', section_id, 'str')
        if group_id is not None:
            route_values['groupId'] = self._serialize.url(
                'group_id', group_id, 'str')
        query_parameters = {}
        if remove_from_section_id is not None:
            query_parameters['removeFromSectionId'] = self._serialize.query(
                'remove_from_section_id', remove_from_section_id, 'str')
        content = self._serialize.body(group, 'Group')
        response = self._send(
            http_method='PUT',
            location_id='2617828b-e850-4375-a92a-04855704d4c3',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('Group', response)

    def get_form_layout(self, process_id, wit_ref_name):
        """GetFormLayout.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :rtype: :class:`<FormLayout> <work-item-tracking.v4_0.models.FormLayout>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        response = self._send(
            http_method='GET',
            location_id='3eacc80a-ddca-4404-857a-6331aac99063',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('FormLayout', response)

    def get_lists_metadata(self):
        """GetListsMetadata.
        [Preview API]
        :rtype: [PickListMetadataModel]
        """
        response = self._send(
            http_method='GET',
            location_id='b45cc931-98e3-44a1-b1cd-2e8e9c6dc1c6',
            version='4.0-preview.1',
            returns_collection=True)
        return self._deserialize('[PickListMetadataModel]', response)

    def create_list(self, picklist):
        """CreateList.
        [Preview API]
        :param :class:`<PickListModel> <work-item-tracking.v4_0.models.PickListModel>` picklist:
        :rtype: :class:`<PickListModel> <work-item-tracking.v4_0.models.PickListModel>`
        """
        content = self._serialize.body(picklist, 'PickListModel')
        response = self._send(
            http_method='POST',
            location_id='0b6179e2-23ce-46b2-b094-2ffa5ee70286',
            version='4.0-preview.1',
            content=content)
        return self._deserialize('PickListModel', response)

    def delete_list(self, list_id):
        """DeleteList.
        [Preview API]
        :param str list_id:
        """
        route_values = {}
        if list_id is not None:
            route_values['listId'] = self._serialize.url(
                'list_id', list_id, 'str')
        self._send(http_method='DELETE',
                   location_id='0b6179e2-23ce-46b2-b094-2ffa5ee70286',
                   version='4.0-preview.1',
                   route_values=route_values)

    def get_list(self, list_id):
        """GetList.
        [Preview API]
        :param str list_id:
        :rtype: :class:`<PickListModel> <work-item-tracking.v4_0.models.PickListModel>`
        """
        route_values = {}
        if list_id is not None:
            route_values['listId'] = self._serialize.url(
                'list_id', list_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='0b6179e2-23ce-46b2-b094-2ffa5ee70286',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('PickListModel', response)

    def update_list(self, picklist, list_id):
        """UpdateList.
        [Preview API]
        :param :class:`<PickListModel> <work-item-tracking.v4_0.models.PickListModel>` picklist:
        :param str list_id:
        :rtype: :class:`<PickListModel> <work-item-tracking.v4_0.models.PickListModel>`
        """
        route_values = {}
        if list_id is not None:
            route_values['listId'] = self._serialize.url(
                'list_id', list_id, 'str')
        content = self._serialize.body(picklist, 'PickListModel')
        response = self._send(
            http_method='PUT',
            location_id='0b6179e2-23ce-46b2-b094-2ffa5ee70286',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('PickListModel', response)

    def add_page(self, page, process_id, wit_ref_name):
        """AddPage.
        [Preview API]
        :param :class:`<Page> <work-item-tracking.v4_0.models.Page>` page:
        :param str process_id:
        :param str wit_ref_name:
        :rtype: :class:`<Page> <work-item-tracking.v4_0.models.Page>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        content = self._serialize.body(page, 'Page')
        response = self._send(
            http_method='POST',
            location_id='1b4ac126-59b2-4f37-b4df-0a48ba807edb',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Page', response)

    def edit_page(self, page, process_id, wit_ref_name):
        """EditPage.
        [Preview API]
        :param :class:`<Page> <work-item-tracking.v4_0.models.Page>` page:
        :param str process_id:
        :param str wit_ref_name:
        :rtype: :class:`<Page> <work-item-tracking.v4_0.models.Page>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        content = self._serialize.body(page, 'Page')
        response = self._send(
            http_method='PATCH',
            location_id='1b4ac126-59b2-4f37-b4df-0a48ba807edb',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('Page', response)

    def remove_page(self, process_id, wit_ref_name, page_id):
        """RemovePage.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :param str page_id:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if page_id is not None:
            route_values['pageId'] = self._serialize.url(
                'page_id', page_id, 'str')
        self._send(http_method='DELETE',
                   location_id='1b4ac126-59b2-4f37-b4df-0a48ba807edb',
                   version='4.0-preview.1',
                   route_values=route_values)

    def create_state_definition(self, state_model, process_id, wit_ref_name):
        """CreateStateDefinition.
        [Preview API]
        :param :class:`<WorkItemStateInputModel> <work-item-tracking.v4_0.models.WorkItemStateInputModel>` state_model:
        :param str process_id:
        :param str wit_ref_name:
        :rtype: :class:`<WorkItemStateResultModel> <work-item-tracking.v4_0.models.WorkItemStateResultModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        content = self._serialize.body(state_model, 'WorkItemStateInputModel')
        response = self._send(
            http_method='POST',
            location_id='4303625d-08f4-4461-b14b-32c65bba5599',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemStateResultModel', response)

    def delete_state_definition(self, process_id, wit_ref_name, state_id):
        """DeleteStateDefinition.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :param str state_id:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if state_id is not None:
            route_values['stateId'] = self._serialize.url(
                'state_id', state_id, 'str')
        self._send(http_method='DELETE',
                   location_id='4303625d-08f4-4461-b14b-32c65bba5599',
                   version='4.0-preview.1',
                   route_values=route_values)

    def get_state_definition(self, process_id, wit_ref_name, state_id):
        """GetStateDefinition.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :param str state_id:
        :rtype: :class:`<WorkItemStateResultModel> <work-item-tracking.v4_0.models.WorkItemStateResultModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if state_id is not None:
            route_values['stateId'] = self._serialize.url(
                'state_id', state_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='4303625d-08f4-4461-b14b-32c65bba5599',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('WorkItemStateResultModel', response)

    def get_state_definitions(self, process_id, wit_ref_name):
        """GetStateDefinitions.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :rtype: [WorkItemStateResultModel]
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        response = self._send(
            http_method='GET',
            location_id='4303625d-08f4-4461-b14b-32c65bba5599',
            version='4.0-preview.1',
            route_values=route_values,
            returns_collection=True)
        return self._deserialize('[WorkItemStateResultModel]', response)

    def hide_state_definition(self, hide_state_model, process_id, wit_ref_name,
                              state_id):
        """HideStateDefinition.
        [Preview API]
        :param :class:`<HideStateModel> <work-item-tracking.v4_0.models.HideStateModel>` hide_state_model:
        :param str process_id:
        :param str wit_ref_name:
        :param str state_id:
        :rtype: :class:`<WorkItemStateResultModel> <work-item-tracking.v4_0.models.WorkItemStateResultModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if state_id is not None:
            route_values['stateId'] = self._serialize.url(
                'state_id', state_id, 'str')
        content = self._serialize.body(hide_state_model, 'HideStateModel')
        response = self._send(
            http_method='PUT',
            location_id='4303625d-08f4-4461-b14b-32c65bba5599',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemStateResultModel', response)

    def update_state_definition(self, state_model, process_id, wit_ref_name,
                                state_id):
        """UpdateStateDefinition.
        [Preview API]
        :param :class:`<WorkItemStateInputModel> <work-item-tracking.v4_0.models.WorkItemStateInputModel>` state_model:
        :param str process_id:
        :param str wit_ref_name:
        :param str state_id:
        :rtype: :class:`<WorkItemStateResultModel> <work-item-tracking.v4_0.models.WorkItemStateResultModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        if state_id is not None:
            route_values['stateId'] = self._serialize.url(
                'state_id', state_id, 'str')
        content = self._serialize.body(state_model, 'WorkItemStateInputModel')
        response = self._send(
            http_method='PATCH',
            location_id='4303625d-08f4-4461-b14b-32c65bba5599',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemStateResultModel', response)

    def add_behavior_to_work_item_type(self, behavior, process_id,
                                       wit_ref_name_for_behaviors):
        """AddBehaviorToWorkItemType.
        [Preview API]
        :param :class:`<WorkItemTypeBehavior> <work-item-tracking.v4_0.models.WorkItemTypeBehavior>` behavior:
        :param str process_id:
        :param str wit_ref_name_for_behaviors:
        :rtype: :class:`<WorkItemTypeBehavior> <work-item-tracking.v4_0.models.WorkItemTypeBehavior>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_behaviors is not None:
            route_values['witRefNameForBehaviors'] = self._serialize.url(
                'wit_ref_name_for_behaviors', wit_ref_name_for_behaviors,
                'str')
        content = self._serialize.body(behavior, 'WorkItemTypeBehavior')
        response = self._send(
            http_method='POST',
            location_id='921dfb88-ef57-4c69-94e5-dd7da2d7031d',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemTypeBehavior', response)

    def get_behavior_for_work_item_type(self, process_id,
                                        wit_ref_name_for_behaviors,
                                        behavior_ref_name):
        """GetBehaviorForWorkItemType.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name_for_behaviors:
        :param str behavior_ref_name:
        :rtype: :class:`<WorkItemTypeBehavior> <work-item-tracking.v4_0.models.WorkItemTypeBehavior>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_behaviors is not None:
            route_values['witRefNameForBehaviors'] = self._serialize.url(
                'wit_ref_name_for_behaviors', wit_ref_name_for_behaviors,
                'str')
        if behavior_ref_name is not None:
            route_values['behaviorRefName'] = self._serialize.url(
                'behavior_ref_name', behavior_ref_name, 'str')
        response = self._send(
            http_method='GET',
            location_id='921dfb88-ef57-4c69-94e5-dd7da2d7031d',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('WorkItemTypeBehavior', response)

    def get_behaviors_for_work_item_type(self, process_id,
                                         wit_ref_name_for_behaviors):
        """GetBehaviorsForWorkItemType.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name_for_behaviors:
        :rtype: [WorkItemTypeBehavior]
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_behaviors is not None:
            route_values['witRefNameForBehaviors'] = self._serialize.url(
                'wit_ref_name_for_behaviors', wit_ref_name_for_behaviors,
                'str')
        response = self._send(
            http_method='GET',
            location_id='921dfb88-ef57-4c69-94e5-dd7da2d7031d',
            version='4.0-preview.1',
            route_values=route_values,
            returns_collection=True)
        return self._deserialize('[WorkItemTypeBehavior]', response)

    def remove_behavior_from_work_item_type(self, process_id,
                                            wit_ref_name_for_behaviors,
                                            behavior_ref_name):
        """RemoveBehaviorFromWorkItemType.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name_for_behaviors:
        :param str behavior_ref_name:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_behaviors is not None:
            route_values['witRefNameForBehaviors'] = self._serialize.url(
                'wit_ref_name_for_behaviors', wit_ref_name_for_behaviors,
                'str')
        if behavior_ref_name is not None:
            route_values['behaviorRefName'] = self._serialize.url(
                'behavior_ref_name', behavior_ref_name, 'str')
        self._send(http_method='DELETE',
                   location_id='921dfb88-ef57-4c69-94e5-dd7da2d7031d',
                   version='4.0-preview.1',
                   route_values=route_values)

    def update_behavior_to_work_item_type(self, behavior, process_id,
                                          wit_ref_name_for_behaviors):
        """UpdateBehaviorToWorkItemType.
        [Preview API]
        :param :class:`<WorkItemTypeBehavior> <work-item-tracking.v4_0.models.WorkItemTypeBehavior>` behavior:
        :param str process_id:
        :param str wit_ref_name_for_behaviors:
        :rtype: :class:`<WorkItemTypeBehavior> <work-item-tracking.v4_0.models.WorkItemTypeBehavior>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_behaviors is not None:
            route_values['witRefNameForBehaviors'] = self._serialize.url(
                'wit_ref_name_for_behaviors', wit_ref_name_for_behaviors,
                'str')
        content = self._serialize.body(behavior, 'WorkItemTypeBehavior')
        response = self._send(
            http_method='PATCH',
            location_id='921dfb88-ef57-4c69-94e5-dd7da2d7031d',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemTypeBehavior', response)

    def create_work_item_type(self, work_item_type, process_id):
        """CreateWorkItemType.
        [Preview API]
        :param :class:`<WorkItemTypeModel> <work-item-tracking.v4_0.models.WorkItemTypeModel>` work_item_type:
        :param str process_id:
        :rtype: :class:`<WorkItemTypeModel> <work-item-tracking.v4_0.models.WorkItemTypeModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        content = self._serialize.body(work_item_type, 'WorkItemTypeModel')
        response = self._send(
            http_method='POST',
            location_id='1ce0acad-4638-49c3-969c-04aa65ba6bea',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemTypeModel', response)

    def delete_work_item_type(self, process_id, wit_ref_name):
        """DeleteWorkItemType.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        self._send(http_method='DELETE',
                   location_id='1ce0acad-4638-49c3-969c-04aa65ba6bea',
                   version='4.0-preview.1',
                   route_values=route_values)

    def get_work_item_type(self, process_id, wit_ref_name, expand=None):
        """GetWorkItemType.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name:
        :param str expand:
        :rtype: :class:`<WorkItemTypeModel> <work-item-tracking.v4_0.models.WorkItemTypeModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        query_parameters = {}
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query(
                'expand', expand, 'str')
        response = self._send(
            http_method='GET',
            location_id='1ce0acad-4638-49c3-969c-04aa65ba6bea',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('WorkItemTypeModel', response)

    def get_work_item_types(self, process_id, expand=None):
        """GetWorkItemTypes.
        [Preview API]
        :param str process_id:
        :param str expand:
        :rtype: [WorkItemTypeModel]
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        query_parameters = {}
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query(
                'expand', expand, 'str')
        response = self._send(
            http_method='GET',
            location_id='1ce0acad-4638-49c3-969c-04aa65ba6bea',
            version='4.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            returns_collection=True)
        return self._deserialize('[WorkItemTypeModel]', response)

    def update_work_item_type(self, work_item_type_update, process_id,
                              wit_ref_name):
        """UpdateWorkItemType.
        [Preview API]
        :param :class:`<WorkItemTypeUpdateModel> <work-item-tracking.v4_0.models.WorkItemTypeUpdateModel>` work_item_type_update:
        :param str process_id:
        :param str wit_ref_name:
        :rtype: :class:`<WorkItemTypeModel> <work-item-tracking.v4_0.models.WorkItemTypeModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name is not None:
            route_values['witRefName'] = self._serialize.url(
                'wit_ref_name', wit_ref_name, 'str')
        content = self._serialize.body(work_item_type_update,
                                       'WorkItemTypeUpdateModel')
        response = self._send(
            http_method='PATCH',
            location_id='1ce0acad-4638-49c3-969c-04aa65ba6bea',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemTypeModel', response)

    def add_field_to_work_item_type(self, field, process_id,
                                    wit_ref_name_for_fields):
        """AddFieldToWorkItemType.
        [Preview API]
        :param :class:`<WorkItemTypeFieldModel> <work-item-tracking.v4_0.models.WorkItemTypeFieldModel>` field:
        :param str process_id:
        :param str wit_ref_name_for_fields:
        :rtype: :class:`<WorkItemTypeFieldModel> <work-item-tracking.v4_0.models.WorkItemTypeFieldModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_fields is not None:
            route_values['witRefNameForFields'] = self._serialize.url(
                'wit_ref_name_for_fields', wit_ref_name_for_fields, 'str')
        content = self._serialize.body(field, 'WorkItemTypeFieldModel')
        response = self._send(
            http_method='POST',
            location_id='976713b4-a62e-499e-94dc-eeb869ea9126',
            version='4.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WorkItemTypeFieldModel', response)

    def get_work_item_type_field(self, process_id, wit_ref_name_for_fields,
                                 field_ref_name):
        """GetWorkItemTypeField.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name_for_fields:
        :param str field_ref_name:
        :rtype: :class:`<WorkItemTypeFieldModel> <work-item-tracking.v4_0.models.WorkItemTypeFieldModel>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_fields is not None:
            route_values['witRefNameForFields'] = self._serialize.url(
                'wit_ref_name_for_fields', wit_ref_name_for_fields, 'str')
        if field_ref_name is not None:
            route_values['fieldRefName'] = self._serialize.url(
                'field_ref_name', field_ref_name, 'str')
        response = self._send(
            http_method='GET',
            location_id='976713b4-a62e-499e-94dc-eeb869ea9126',
            version='4.0-preview.1',
            route_values=route_values)
        return self._deserialize('WorkItemTypeFieldModel', response)

    def get_work_item_type_fields(self, process_id, wit_ref_name_for_fields):
        """GetWorkItemTypeFields.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name_for_fields:
        :rtype: [WorkItemTypeFieldModel]
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_fields is not None:
            route_values['witRefNameForFields'] = self._serialize.url(
                'wit_ref_name_for_fields', wit_ref_name_for_fields, 'str')
        response = self._send(
            http_method='GET',
            location_id='976713b4-a62e-499e-94dc-eeb869ea9126',
            version='4.0-preview.1',
            route_values=route_values,
            returns_collection=True)
        return self._deserialize('[WorkItemTypeFieldModel]', response)

    def remove_field_from_work_item_type(self, process_id,
                                         wit_ref_name_for_fields,
                                         field_ref_name):
        """RemoveFieldFromWorkItemType.
        [Preview API]
        :param str process_id:
        :param str wit_ref_name_for_fields:
        :param str field_ref_name:
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        if wit_ref_name_for_fields is not None:
            route_values['witRefNameForFields'] = self._serialize.url(
                'wit_ref_name_for_fields', wit_ref_name_for_fields, 'str')
        if field_ref_name is not None:
            route_values['fieldRefName'] = self._serialize.url(
                'field_ref_name', field_ref_name, 'str')
        self._send(http_method='DELETE',
                   location_id='976713b4-a62e-499e-94dc-eeb869ea9126',
                   version='4.0-preview.1',
                   route_values=route_values)
コード例 #35
0
class IdentityClient(Client):
    """Identity
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """

    def __init__(self, base_url=None, creds=None):
        super(IdentityClient, self).__init__(base_url, creds)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '8a3d49b8-91f0-46ef-b33d-dda338c25db3'

    def create_groups(self, container):
        """CreateGroups.
        :param :class:`<object> <azure.devops.v5_0.identity.models.object>` container:
        :rtype: [Identity]
        """
        content = self._serialize.body(container, 'object')
        response = self._send(http_method='POST',
                              location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                              version='5.0',
                              content=content)
        return self._deserialize('[Identity]', self._unwrap_collection(response))

    def delete_group(self, group_id):
        """DeleteGroup.
        :param str group_id:
        """
        route_values = {}
        if group_id is not None:
            route_values['groupId'] = self._serialize.url('group_id', group_id, 'str')
        self._send(http_method='DELETE',
                   location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                   version='5.0',
                   route_values=route_values)

    def list_groups(self, scope_ids=None, recurse=None, deleted=None, properties=None):
        """ListGroups.
        :param str scope_ids:
        :param bool recurse:
        :param bool deleted:
        :param str properties:
        :rtype: [Identity]
        """
        query_parameters = {}
        if scope_ids is not None:
            query_parameters['scopeIds'] = self._serialize.query('scope_ids', scope_ids, 'str')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        if deleted is not None:
            query_parameters['deleted'] = self._serialize.query('deleted', deleted, 'bool')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='5966283b-4196-4d57-9211-1b68f41ec1c2',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[Identity]', self._unwrap_collection(response))

    def get_identity_changes(self, identity_sequence_id, group_sequence_id, organization_identity_sequence_id=None, page_size=None, scope_id=None):
        """GetIdentityChanges.
        :param int identity_sequence_id:
        :param int group_sequence_id:
        :param int organization_identity_sequence_id:
        :param int page_size:
        :param str scope_id:
        :rtype: :class:`<ChangedIdentities> <azure.devops.v5_0.identity.models.ChangedIdentities>`
        """
        query_parameters = {}
        if identity_sequence_id is not None:
            query_parameters['identitySequenceId'] = self._serialize.query('identity_sequence_id', identity_sequence_id, 'int')
        if group_sequence_id is not None:
            query_parameters['groupSequenceId'] = self._serialize.query('group_sequence_id', group_sequence_id, 'int')
        if organization_identity_sequence_id is not None:
            query_parameters['organizationIdentitySequenceId'] = self._serialize.query('organization_identity_sequence_id', organization_identity_sequence_id, 'int')
        if page_size is not None:
            query_parameters['pageSize'] = self._serialize.query('page_size', page_size, 'int')
        if scope_id is not None:
            query_parameters['scopeId'] = self._serialize.query('scope_id', scope_id, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('ChangedIdentities', response)

    def get_user_identity_ids_by_domain_id(self, domain_id):
        """GetUserIdentityIdsByDomainId.
        :param str domain_id:
        :rtype: [str]
        """
        query_parameters = {}
        if domain_id is not None:
            query_parameters['domainId'] = self._serialize.query('domain_id', domain_id, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))

    def read_identities(self, descriptors=None, identity_ids=None, subject_descriptors=None, search_filter=None, filter_value=None, query_membership=None, properties=None, include_restricted_visibility=None, options=None):
        """ReadIdentities.
        :param str descriptors:
        :param str identity_ids:
        :param str subject_descriptors:
        :param str search_filter:
        :param str filter_value:
        :param str query_membership:
        :param str properties:
        :param bool include_restricted_visibility:
        :param str options:
        :rtype: [Identity]
        """
        query_parameters = {}
        if descriptors is not None:
            query_parameters['descriptors'] = self._serialize.query('descriptors', descriptors, 'str')
        if identity_ids is not None:
            query_parameters['identityIds'] = self._serialize.query('identity_ids', identity_ids, 'str')
        if subject_descriptors is not None:
            query_parameters['subjectDescriptors'] = self._serialize.query('subject_descriptors', subject_descriptors, 'str')
        if search_filter is not None:
            query_parameters['searchFilter'] = self._serialize.query('search_filter', search_filter, 'str')
        if filter_value is not None:
            query_parameters['filterValue'] = self._serialize.query('filter_value', filter_value, 'str')
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query('query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        if include_restricted_visibility is not None:
            query_parameters['includeRestrictedVisibility'] = self._serialize.query('include_restricted_visibility', include_restricted_visibility, 'bool')
        if options is not None:
            query_parameters['options'] = self._serialize.query('options', options, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[Identity]', self._unwrap_collection(response))

    def read_identities_by_scope(self, scope_id, query_membership=None, properties=None):
        """ReadIdentitiesByScope.
        :param str scope_id:
        :param str query_membership:
        :param str properties:
        :rtype: [Identity]
        """
        query_parameters = {}
        if scope_id is not None:
            query_parameters['scopeId'] = self._serialize.query('scope_id', scope_id, 'str')
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query('query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              query_parameters=query_parameters)
        return self._deserialize('[Identity]', self._unwrap_collection(response))

    def read_identity(self, identity_id, query_membership=None, properties=None):
        """ReadIdentity.
        :param str identity_id:
        :param str query_membership:
        :param str properties:
        :rtype: :class:`<Identity> <azure.devops.v5_0.identity.models.Identity>`
        """
        route_values = {}
        if identity_id is not None:
            route_values['identityId'] = self._serialize.url('identity_id', identity_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query('query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('Identity', response)

    def update_identities(self, identities):
        """UpdateIdentities.
        :param :class:`<VssJsonCollectionWrapper> <azure.devops.v5_0.identity.models.VssJsonCollectionWrapper>` identities:
        :rtype: [IdentityUpdateData]
        """
        content = self._serialize.body(identities, 'VssJsonCollectionWrapper')
        response = self._send(http_method='PUT',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              content=content)
        return self._deserialize('[IdentityUpdateData]', self._unwrap_collection(response))

    def update_identity(self, identity, identity_id):
        """UpdateIdentity.
        :param :class:`<Identity> <azure.devops.v5_0.identity.models.Identity>` identity:
        :param str identity_id:
        """
        route_values = {}
        if identity_id is not None:
            route_values['identityId'] = self._serialize.url('identity_id', identity_id, 'str')
        content = self._serialize.body(identity, 'Identity')
        self._send(http_method='PUT',
                   location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                   version='5.0',
                   route_values=route_values,
                   content=content)

    def create_identity(self, framework_identity_info):
        """CreateIdentity.
        :param :class:`<FrameworkIdentityInfo> <azure.devops.v5_0.identity.models.FrameworkIdentityInfo>` framework_identity_info:
        :rtype: :class:`<Identity> <azure.devops.v5_0.identity.models.Identity>`
        """
        content = self._serialize.body(framework_identity_info, 'FrameworkIdentityInfo')
        response = self._send(http_method='PUT',
                              location_id='dd55f0eb-6ea2-4fe4-9ebe-919e7dd1dfb4',
                              version='5.0',
                              content=content)
        return self._deserialize('Identity', response)

    def get_max_sequence_id(self):
        """GetMaxSequenceId.
        Read the max sequence id of all the identities.
        :rtype: long
        """
        response = self._send(http_method='GET',
                              location_id='e4a70778-cb2c-4e85-b7cc-3f3c7ae2d408',
                              version='5.0')
        return self._deserialize('long', response)

    def get_self(self):
        """GetSelf.
        Read identity of the home tenant request user.
        :rtype: :class:`<IdentitySelf> <azure.devops.v5_0.identity.models.IdentitySelf>`
        """
        response = self._send(http_method='GET',
                              location_id='4bb02b5b-c120-4be2-b68e-21f7c50a4b82',
                              version='5.0')
        return self._deserialize('IdentitySelf', response)
コード例 #36
0
class WebSiteManagementClient(object):
    """WebSite Management Client

    :ivar config: Configuration for client.
    :vartype config: WebSiteManagementClientConfiguration

    :ivar app_service_certificate_orders: AppServiceCertificateOrders operations
    :vartype app_service_certificate_orders: azure.mgmt.web.operations.AppServiceCertificateOrdersOperations
    :ivar domains: Domains operations
    :vartype domains: azure.mgmt.web.operations.DomainsOperations
    :ivar top_level_domains: TopLevelDomains operations
    :vartype top_level_domains: azure.mgmt.web.operations.TopLevelDomainsOperations
    :ivar certificates: Certificates operations
    :vartype certificates: azure.mgmt.web.operations.CertificatesOperations
    :ivar deleted_web_apps: DeletedWebApps operations
    :vartype deleted_web_apps: azure.mgmt.web.operations.DeletedWebAppsOperations
    :ivar provider: Provider operations
    :vartype provider: azure.mgmt.web.operations.ProviderOperations
    :ivar recommendations: Recommendations operations
    :vartype recommendations: azure.mgmt.web.operations.RecommendationsOperations
    :ivar web_apps: WebApps operations
    :vartype web_apps: azure.mgmt.web.operations.WebAppsOperations
    :ivar app_service_environments: AppServiceEnvironments operations
    :vartype app_service_environments: azure.mgmt.web.operations.AppServiceEnvironmentsOperations
    :ivar app_service_plans: AppServicePlans operations
    :vartype app_service_plans: azure.mgmt.web.operations.AppServicePlansOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Your Azure subscription ID. This is a
     GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = WebSiteManagementClientConfiguration(credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.app_service_certificate_orders = AppServiceCertificateOrdersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.domains = DomainsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.top_level_domains = TopLevelDomainsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.certificates = CertificatesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.deleted_web_apps = DeletedWebAppsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.provider = ProviderOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.recommendations = RecommendationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.web_apps = WebAppsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.app_service_environments = AppServiceEnvironmentsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.app_service_plans = AppServicePlansOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def get_publishing_user(
            self, custom_headers=None, raw=False, **operation_config):
        """Gets publishing user.

        Gets publishing user.

        :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: User or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.User or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/providers/Microsoft.Web/publishingUsers/web'

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def update_publishing_user(
            self, user_details, custom_headers=None, raw=False, **operation_config):
        """Updates publishing user.

        Updates publishing user.

        :param user_details: Details of publishing user
        :type user_details: ~azure.mgmt.web.models.User
        :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: User or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.User or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/providers/Microsoft.Web/publishingUsers/web'

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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(user_details, 'User')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def list_source_controls(
            self, custom_headers=None, raw=False, **operation_config):
        """Gets the source controls available for Azure websites.

        Gets the source controls available for Azure websites.

        :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 SourceControl
        :rtype:
         ~azure.mgmt.web.models.SourceControlPaged[~azure.mgmt.web.models.SourceControl]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/providers/Microsoft.Web/sourcecontrols'

                # Construct parameters
                query_parameters = {}
                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

            if response.status_code not in [200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            return response

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

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

        return deserialized

    def get_source_control(
            self, source_control_type, custom_headers=None, raw=False, **operation_config):
        """Gets source control token.

        Gets source control token.

        :param source_control_type: Type of source control
        :type source_control_type: 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: SourceControl or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.SourceControl or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/providers/Microsoft.Web/sourcecontrols/{sourceControlType}'
        path_format_arguments = {
            'sourceControlType': self._serialize.url("source_control_type", source_control_type, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def update_source_control(
            self, source_control_type, request_message, custom_headers=None, raw=False, **operation_config):
        """Updates source control token.

        Updates source control token.

        :param source_control_type: Type of source control
        :type source_control_type: str
        :param request_message: Source control token information
        :type request_message: ~azure.mgmt.web.models.SourceControl
        :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: SourceControl or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.SourceControl or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/providers/Microsoft.Web/sourcecontrols/{sourceControlType}'
        path_format_arguments = {
            'sourceControlType': self._serialize.url("source_control_type", source_control_type, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['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(request_message, 'SourceControl')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def check_name_availability(
            self, name, type, is_fqdn=None, custom_headers=None, raw=False, **operation_config):
        """Check if a resource name is available.

        Check if a resource name is available.

        :param name: Resource name to verify.
        :type name: str
        :param type: Resource type used for verification. Possible values
         include: 'Site', 'Slot', 'HostingEnvironment'
        :type type: str or ~azure.mgmt.web.models.CheckNameResourceTypes
        :param is_fqdn: Is fully qualified domain name.
        :type is_fqdn: 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 operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: ResourceNameAvailability or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.ResourceNameAvailability or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        request = models.ResourceNameAvailabilityRequest(name=name, type=type, is_fqdn=is_fqdn)

        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/checknameavailability'
        path_format_arguments = {
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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(request, 'ResourceNameAvailabilityRequest')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def get_subscription_deployment_locations(
            self, custom_headers=None, raw=False, **operation_config):
        """Gets list of available geo regions plus ministamps.

        Gets list of available geo regions plus ministamps.

        :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: DeploymentLocations or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.DeploymentLocations or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/deploymentLocations'
        path_format_arguments = {
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def list_geo_regions(
            self, sku=None, linux_workers_enabled=None, custom_headers=None, raw=False, **operation_config):
        """Get a list of available geographical regions.

        Get a list of available geographical regions.

        :param sku: Name of SKU used to filter the regions. Possible values
         include: 'Free', 'Shared', 'Basic', 'Standard', 'Premium',
         'PremiumV2', 'Dynamic', 'Isolated'
        :type sku: str or ~azure.mgmt.web.models.SkuName
        :param linux_workers_enabled: Specify <code>true</code> if you want to
         filter to only regions that support Linux workers.
        :type linux_workers_enabled: 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 operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: An iterator like instance of GeoRegion
        :rtype:
         ~azure.mgmt.web.models.GeoRegionPaged[~azure.mgmt.web.models.GeoRegion]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/geoRegions'
                path_format_arguments = {
                    '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 = {}
                if sku is not None:
                    query_parameters['sku'] = self._serialize.query("sku", sku, 'str')
                if linux_workers_enabled is not None:
                    query_parameters['linuxWorkersEnabled'] = self._serialize.query("linux_workers_enabled", linux_workers_enabled, 'bool')
                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

            if response.status_code not in [200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            return response

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

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

        return deserialized

    def list_premier_add_on_offers(
            self, custom_headers=None, raw=False, **operation_config):
        """List all premier add-on offers.

        List all premier add-on offers.

        :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 PremierAddOnOffer
        :rtype:
         ~azure.mgmt.web.models.PremierAddOnOfferPaged[~azure.mgmt.web.models.PremierAddOnOffer]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/premieraddonoffers'
                path_format_arguments = {
                    '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 = {}
                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(
                request, header_parameters, **operation_config)

            if response.status_code not in [200]:
                exp = CloudError(response)
                exp.request_id = response.headers.get('x-ms-request-id')
                raise exp

            return response

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

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

        return deserialized

    def list_skus(
            self, custom_headers=None, raw=False, **operation_config):
        """List all SKUs.

        List all SKUs.

        :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: SkuInfos or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.SkuInfos or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/skus'
        path_format_arguments = {
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def verify_hosting_environment_vnet(
            self, parameters, custom_headers=None, raw=False, **operation_config):
        """Verifies if this VNET is compatible with an App Service Environment by
        analyzing the Network Security Group rules.

        Verifies if this VNET is compatible with an App Service Environment by
        analyzing the Network Security Group rules.

        :param parameters: VNET information
        :type parameters: ~azure.mgmt.web.models.VnetParameters
        :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: VnetValidationFailureDetails or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.VnetValidationFailureDetails or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/verifyHostingEnvironmentVnet'
        path_format_arguments = {
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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, 'VnetParameters')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def move(
            self, resource_group_name, target_resource_group=None, resources=None, custom_headers=None, raw=False, **operation_config):
        """Move resources between resource groups.

        Move resources between resource groups.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param target_resource_group:
        :type target_resource_group: str
        :param resources:
        :type resources: list[str]
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        move_resource_envelope = models.CsmMoveResourceEnvelope(target_resource_group=target_resource_group, resources=resources)

        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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(move_resource_envelope, 'CsmMoveResourceEnvelope')

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

        if response.status_code not in [204]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

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

    def validate(
            self, resource_group_name, validate_request, custom_headers=None, raw=False, **operation_config):
        """Validate if a resource can be created.

        Validate if a resource can be created.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param validate_request: Request with the resources to validate.
        :type validate_request: ~azure.mgmt.web.models.ValidateRequest
        :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: ValidateResponse or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.web.models.ValidateResponse or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/validate'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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(validate_request, 'ValidateRequest')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    def validate_move(
            self, resource_group_name, target_resource_group=None, resources=None, custom_headers=None, raw=False, **operation_config):
        """Validate whether a resource can be moved.

        Validate whether a resource can be moved.

        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param target_resource_group:
        :type target_resource_group: str
        :param resources:
        :type resources: list[str]
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :return: None or ClientRawResponse if raw=true
        :rtype: None or ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        move_resource_envelope = models.CsmMoveResourceEnvelope(target_resource_group=target_resource_group, resources=resources)

        api_version = "2016-03-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/validateMoveResources'
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'),
            '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 = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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(move_resource_envelope, 'CsmMoveResourceEnvelope')

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

        if response.status_code not in [204]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
コード例 #37
0
class LicensingClient(Client):
    """Licensing
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(LicensingClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = 'c73a23a1-59bb-458c-8ce3-02c83215e015'

    def get_extension_license_usage(self):
        """GetExtensionLicenseUsage.
        [Preview API] Returns Licensing info about paid extensions assigned to user passed into GetExtensionsAssignedToAccount
        :rtype: [AccountLicenseExtensionUsage]
        """
        response = self._send(
            http_method='GET',
            location_id='01bce8d3-c130-480f-a332-474ae3f6662e',
            version='5.0-preview.1')
        return self._deserialize('[AccountLicenseExtensionUsage]',
                                 self._unwrap_collection(response))

    def get_certificate(self, **kwargs):
        """GetCertificate.
        [Preview API]
        :rtype: object
        """
        response = self._send(
            http_method='GET',
            location_id='2e0dbce7-a327-4bc0-a291-056139393f6d',
            version='5.0-preview.1',
            accept_media_type='application/octet-stream')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)

    def get_client_rights(self,
                          right_name=None,
                          product_version=None,
                          edition=None,
                          rel_type=None,
                          include_certificate=None,
                          canary=None,
                          machine_id=None):
        """GetClientRights.
        [Preview API]
        :param str right_name:
        :param str product_version:
        :param str edition:
        :param str rel_type:
        :param bool include_certificate:
        :param str canary:
        :param str machine_id:
        :rtype: :class:`<ClientRightsContainer> <azure.devops.v5_0.licensing.models.ClientRightsContainer>`
        """
        route_values = {}
        if right_name is not None:
            route_values['rightName'] = self._serialize.url(
                'right_name', right_name, 'str')
        query_parameters = {}
        if product_version is not None:
            query_parameters['productVersion'] = self._serialize.query(
                'product_version', product_version, 'str')
        if edition is not None:
            query_parameters['edition'] = self._serialize.query(
                'edition', edition, 'str')
        if rel_type is not None:
            query_parameters['relType'] = self._serialize.query(
                'rel_type', rel_type, 'str')
        if include_certificate is not None:
            query_parameters['includeCertificate'] = self._serialize.query(
                'include_certificate', include_certificate, 'bool')
        if canary is not None:
            query_parameters['canary'] = self._serialize.query(
                'canary', canary, 'str')
        if machine_id is not None:
            query_parameters['machineId'] = self._serialize.query(
                'machine_id', machine_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='643c72da-eaee-4163-9f07-d748ef5c2a0c',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('ClientRightsContainer', response)

    def assign_available_account_entitlement(self,
                                             user_id,
                                             dont_notify_user=None,
                                             origin=None):
        """AssignAvailableAccountEntitlement.
        [Preview API] Assign an available entitilement to a user
        :param str user_id: The user to which to assign the entitilement
        :param bool dont_notify_user:
        :param str origin:
        :rtype: :class:`<AccountEntitlement> <azure.devops.v5_0.licensing.models.AccountEntitlement>`
        """
        query_parameters = {}
        if user_id is not None:
            query_parameters['userId'] = self._serialize.query(
                'user_id', user_id, 'str')
        if dont_notify_user is not None:
            query_parameters['dontNotifyUser'] = self._serialize.query(
                'dont_notify_user', dont_notify_user, 'bool')
        if origin is not None:
            query_parameters['origin'] = self._serialize.query(
                'origin', origin, 'str')
        response = self._send(
            http_method='POST',
            location_id='c01e9fd5-0d8c-4d5e-9a68-734bd8da6a38',
            version='5.0-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('AccountEntitlement', response)

    def get_account_entitlement(self):
        """GetAccountEntitlement.
        [Preview API] Gets the account entitlement of the current user it is mapped to _apis/licensing/entitlements/me so specifically is looking for the user of the request
        :rtype: :class:`<AccountEntitlement> <azure.devops.v5_0.licensing.models.AccountEntitlement>`
        """
        response = self._send(
            http_method='GET',
            location_id='c01e9fd5-0d8c-4d5e-9a68-734bd8da6a38',
            version='5.0-preview.1')
        return self._deserialize('AccountEntitlement', response)

    def get_account_entitlements(self, top=None, skip=None):
        """GetAccountEntitlements.
        [Preview API] Gets top (top) entitlements for users in the account from offset (skip) order by DateCreated ASC
        :param int top: number of accounts to return
        :param int skip: records to skip, null is interpreted as 0
        :rtype: [AccountEntitlement]
        """
        query_parameters = {}
        if top is not None:
            query_parameters['top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='ea37be6f-8cd7-48dd-983d-2b72d6e3da0f',
            version='5.0-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[AccountEntitlement]',
                                 self._unwrap_collection(response))

    def assign_account_entitlement_for_user(self,
                                            body,
                                            user_id,
                                            dont_notify_user=None,
                                            origin=None):
        """AssignAccountEntitlementForUser.
        [Preview API] Assign an explicit account entitlement
        :param :class:`<AccountEntitlementUpdateModel> <azure.devops.v5_0.licensing.models.AccountEntitlementUpdateModel>` body: The update model for the entitlement
        :param str user_id: The id of the user
        :param bool dont_notify_user:
        :param str origin:
        :rtype: :class:`<AccountEntitlement> <azure.devops.v5_0.licensing.models.AccountEntitlement>`
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        query_parameters = {}
        if dont_notify_user is not None:
            query_parameters['dontNotifyUser'] = self._serialize.query(
                'dont_notify_user', dont_notify_user, 'bool')
        if origin is not None:
            query_parameters['origin'] = self._serialize.query(
                'origin', origin, 'str')
        content = self._serialize.body(body, 'AccountEntitlementUpdateModel')
        response = self._send(
            http_method='PUT',
            location_id='6490e566-b299-49a7-a4e4-28749752581f',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('AccountEntitlement', response)

    def delete_user_entitlements(self, user_id):
        """DeleteUserEntitlements.
        [Preview API]
        :param str user_id:
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        self._send(http_method='DELETE',
                   location_id='6490e566-b299-49a7-a4e4-28749752581f',
                   version='5.0-preview.1',
                   route_values=route_values)

    def get_account_entitlement_for_user(self,
                                         user_id,
                                         determine_rights=None,
                                         create_if_not_exists=None):
        """GetAccountEntitlementForUser.
        [Preview API] Get the entitlements for a user
        :param str user_id: The id of the user
        :param bool determine_rights:
        :param bool create_if_not_exists:
        :rtype: :class:`<AccountEntitlement> <azure.devops.v5_0.licensing.models.AccountEntitlement>`
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        query_parameters = {}
        if determine_rights is not None:
            query_parameters['determineRights'] = self._serialize.query(
                'determine_rights', determine_rights, 'bool')
        if create_if_not_exists is not None:
            query_parameters['createIfNotExists'] = self._serialize.query(
                'create_if_not_exists', create_if_not_exists, 'bool')
        response = self._send(
            http_method='GET',
            location_id='6490e566-b299-49a7-a4e4-28749752581f',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('AccountEntitlement', response)

    def get_account_entitlements_batch(self, user_ids):
        """GetAccountEntitlementsBatch.
        [Preview API] Returns AccountEntitlements that are currently assigned to the given list of users in the account
        :param [str] user_ids: List of user Ids.
        :rtype: [AccountEntitlement]
        """
        route_values = {}
        route_values['action'] = 'GetUsersEntitlements'
        content = self._serialize.body(user_ids, '[str]')
        response = self._send(
            http_method='POST',
            location_id='cc3a0130-78ad-4a00-b1ca-49bef42f4656',
            version='5.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[AccountEntitlement]',
                                 self._unwrap_collection(response))

    def obtain_available_account_entitlements(self, user_ids):
        """ObtainAvailableAccountEntitlements.
        [Preview API] Returns AccountEntitlements that are currently assigned to the given list of users in the account
        :param [str] user_ids: List of user Ids.
        :rtype: [AccountEntitlement]
        """
        route_values = {}
        route_values['action'] = 'GetAvailableUsersEntitlements'
        content = self._serialize.body(user_ids, '[str]')
        response = self._send(
            http_method='POST',
            location_id='cc3a0130-78ad-4a00-b1ca-49bef42f4656',
            version='5.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('[AccountEntitlement]',
                                 self._unwrap_collection(response))

    def assign_extension_to_all_eligible_users(self, extension_id):
        """AssignExtensionToAllEligibleUsers.
        [Preview API] Assigns the access to the given extension for all eligible users in the account that do not already have access to the extension though bundle or account assignment
        :param str extension_id: The extension id to assign the access to.
        :rtype: [ExtensionOperationResult]
        """
        route_values = {}
        if extension_id is not None:
            route_values['extensionId'] = self._serialize.url(
                'extension_id', extension_id, 'str')
        response = self._send(
            http_method='PUT',
            location_id='5434f182-7f32-4135-8326-9340d887c08a',
            version='5.0-preview.1',
            route_values=route_values)
        return self._deserialize('[ExtensionOperationResult]',
                                 self._unwrap_collection(response))

    def get_eligible_users_for_extension(self, extension_id, options):
        """GetEligibleUsersForExtension.
        [Preview API] Returns users that are currently eligible to assign the extension to. the list is filtered based on the value of ExtensionFilterOptions
        :param str extension_id: The extension to check the eligibility of the users for.
        :param str options: The options to filter the list.
        :rtype: [str]
        """
        route_values = {}
        if extension_id is not None:
            route_values['extensionId'] = self._serialize.url(
                'extension_id', extension_id, 'str')
        query_parameters = {}
        if options is not None:
            query_parameters['options'] = self._serialize.query(
                'options', options, 'str')
        response = self._send(
            http_method='GET',
            location_id='5434f182-7f32-4135-8326-9340d887c08a',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))

    def get_extension_status_for_users(self, extension_id):
        """GetExtensionStatusForUsers.
        [Preview API] Returns extension assignment status of all account users for the given extension
        :param str extension_id: The extension to check the status of the users for.
        :rtype: {ExtensionAssignmentDetails}
        """
        route_values = {}
        if extension_id is not None:
            route_values['extensionId'] = self._serialize.url(
                'extension_id', extension_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='5434f182-7f32-4135-8326-9340d887c08a',
            version='5.0-preview.1',
            route_values=route_values)
        return self._deserialize('{ExtensionAssignmentDetails}',
                                 self._unwrap_collection(response))

    def assign_extension_to_users(self, body):
        """AssignExtensionToUsers.
        [Preview API] Assigns the access to the given extension for a given list of users
        :param :class:`<ExtensionAssignment> <azure.devops.v5_0.licensing.models.ExtensionAssignment>` body: The extension assignment details.
        :rtype: [ExtensionOperationResult]
        """
        content = self._serialize.body(body, 'ExtensionAssignment')
        response = self._send(
            http_method='PUT',
            location_id='8cec75ea-044f-4245-ab0d-a82dafcc85ea',
            version='5.0-preview.1',
            content=content)
        return self._deserialize('[ExtensionOperationResult]',
                                 self._unwrap_collection(response))

    def get_extensions_assigned_to_user(self, user_id):
        """GetExtensionsAssignedToUser.
        [Preview API] Returns extensions that are currently assigned to the user in the account
        :param str user_id: The user's identity id.
        :rtype: {LicensingSource}
        """
        route_values = {}
        if user_id is not None:
            route_values['userId'] = self._serialize.url(
                'user_id', user_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='8cec75ea-044f-4245-ab0d-a82dafcc85ea',
            version='5.0-preview.1',
            route_values=route_values)
        return self._deserialize('{LicensingSource}',
                                 self._unwrap_collection(response))

    def bulk_get_extensions_assigned_to_users(self, user_ids):
        """BulkGetExtensionsAssignedToUsers.
        [Preview API] Returns extensions that are currrently assigned to the users that are in the account
        :param [str] user_ids:
        :rtype: {[ExtensionSource]}
        """
        content = self._serialize.body(user_ids, '[str]')
        response = self._send(
            http_method='PUT',
            location_id='1d42ddc2-3e7d-4daa-a0eb-e12c1dbd7c72',
            version='5.0-preview.2',
            content=content)
        return self._deserialize('{[ExtensionSource]}',
                                 self._unwrap_collection(response))

    def get_extension_license_data(self, extension_id):
        """GetExtensionLicenseData.
        [Preview API]
        :param str extension_id:
        :rtype: :class:`<ExtensionLicenseData> <azure.devops.v5_0.licensing.models.ExtensionLicenseData>`
        """
        route_values = {}
        if extension_id is not None:
            route_values['extensionId'] = self._serialize.url(
                'extension_id', extension_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='004a420a-7bef-4b7f-8a50-22975d2067cc',
            version='5.0-preview.1',
            route_values=route_values)
        return self._deserialize('ExtensionLicenseData', response)

    def register_extension_license(self, extension_license_data):
        """RegisterExtensionLicense.
        [Preview API]
        :param :class:`<ExtensionLicenseData> <azure.devops.v5_0.licensing.models.ExtensionLicenseData>` extension_license_data:
        :rtype: bool
        """
        content = self._serialize.body(extension_license_data,
                                       'ExtensionLicenseData')
        response = self._send(
            http_method='POST',
            location_id='004a420a-7bef-4b7f-8a50-22975d2067cc',
            version='5.0-preview.1',
            content=content)
        return self._deserialize('bool', response)

    def compute_extension_rights(self, ids):
        """ComputeExtensionRights.
        [Preview API]
        :param [str] ids:
        :rtype: {bool}
        """
        content = self._serialize.body(ids, '[str]')
        response = self._send(
            http_method='POST',
            location_id='5f1dbe21-f748-47c7-b5fd-3770c8bc2c08',
            version='5.0-preview.1',
            content=content)
        return self._deserialize('{bool}', self._unwrap_collection(response))

    def get_extension_rights(self):
        """GetExtensionRights.
        [Preview API]
        :rtype: :class:`<ExtensionRightsResult> <azure.devops.v5_0.licensing.models.ExtensionRightsResult>`
        """
        response = self._send(
            http_method='GET',
            location_id='5f1dbe21-f748-47c7-b5fd-3770c8bc2c08',
            version='5.0-preview.1')
        return self._deserialize('ExtensionRightsResult', response)

    def get_msdn_presence(self):
        """GetMsdnPresence.
        [Preview API]
        """
        self._send(http_method='GET',
                   location_id='69522c3f-eecc-48d0-b333-f69ffb8fa6cc',
                   version='5.0-preview.1')

    def get_entitlements(self):
        """GetEntitlements.
        [Preview API]
        :rtype: [MsdnEntitlement]
        """
        response = self._send(
            http_method='GET',
            location_id='1cc6137e-12d5-4d44-a4f2-765006c9e85d',
            version='5.0-preview.1')
        return self._deserialize('[MsdnEntitlement]',
                                 self._unwrap_collection(response))

    def get_account_licenses_usage(self):
        """GetAccountLicensesUsage.
        [Preview API]
        :rtype: [AccountLicenseUsage]
        """
        response = self._send(
            http_method='GET',
            location_id='d3266b87-d395-4e91-97a5-0215b81a0b7d',
            version='5.0-preview.1')
        return self._deserialize('[AccountLicenseUsage]',
                                 self._unwrap_collection(response))
コード例 #38
0
class SqlManagementClient(object):
    """The Azure SQL Database management API provides a RESTful set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases.

    :ivar config: Configuration for client.
    :vartype config: SqlManagementClientConfiguration

    :ivar servers: Servers operations
    :vartype servers: .operations.ServersOperations
    :ivar databases: Databases operations
    :vartype databases: .operations.DatabasesOperations
    :ivar import_export_operations: ImportExportOperations operations
    :vartype import_export_operations: .operations.ImportExportOperations
    :ivar elastic_pools: ElasticPools operations
    :vartype elastic_pools: .operations.ElasticPoolsOperations
    :ivar recommended_elastic_pools: RecommendedElasticPools operations
    :vartype recommended_elastic_pools: .operations.RecommendedElasticPoolsOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription ID that identifies an Azure
     subscription.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = SqlManagementClientConfiguration(credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.servers = ServersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.databases = DatabasesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.import_export_operations = ImportExportOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.elastic_pools = ElasticPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.recommended_elastic_pools = RecommendedElasticPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def list_operations(
            self, custom_headers=None, raw=False, **operation_config):
        """Lists all of the available SQL Rest API operations.

        :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>`.
        :rtype: :class:`OperationListResult
         <azure.mgmt.sql.models.OperationListResult>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2014-04-01"

        # Construct URL
        url = '/providers/Microsoft.Sql/operations'

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", 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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
コード例 #39
0
class FileContainerClient(VssClient):
    """FileContainer
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """

    def __init__(self, base_url=None, creds=None):
        super(FileContainerClient, self).__init__(base_url, creds)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def create_items(self, items, container_id, scope=None):
        """CreateItems.
        [Preview API] Creates the specified items in in the referenced container.
        :param :class:`<VssJsonCollectionWrapper> <file-container.v4_0.models.VssJsonCollectionWrapper>` items:
        :param int container_id:
        :param str scope: A guid representing the scope of the container. This is often the project id.
        :rtype: [FileContainerItem]
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url('container_id', container_id, 'int')
        query_parameters = {}
        if scope is not None:
            query_parameters['scope'] = self._serialize.query('scope', scope, 'str')
        content = self._serialize.body(items, 'VssJsonCollectionWrapper')
        response = self._send(http_method='POST',
                              location_id='e4f5c81e-e250-447b-9fef-bd48471bea5e',
                              version='4.0-preview.4',
                              route_values=route_values,
                              query_parameters=query_parameters,
                              content=content)
        return self._deserialize('[FileContainerItem]', self._unwrap_collection(response))

    def delete_item(self, container_id, item_path, scope=None):
        """DeleteItem.
        [Preview API] Deletes the specified items in a container.
        :param long container_id: Container Id.
        :param str item_path: Path to delete.
        :param str scope: A guid representing the scope of the container. This is often the project id.
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url('container_id', container_id, 'long')
        query_parameters = {}
        if item_path is not None:
            query_parameters['itemPath'] = self._serialize.query('item_path', item_path, 'str')
        if scope is not None:
            query_parameters['scope'] = self._serialize.query('scope', scope, 'str')
        self._send(http_method='DELETE',
                   location_id='e4f5c81e-e250-447b-9fef-bd48471bea5e',
                   version='4.0-preview.4',
                   route_values=route_values,
                   query_parameters=query_parameters)

    def get_containers(self, scope=None, artifact_uris=None):
        """GetContainers.
        [Preview API] Gets containers filtered by a comma separated list of artifact uris within the same scope, if not specified returns all containers
        :param str scope: A guid representing the scope of the container. This is often the project id.
        :param str artifact_uris:
        :rtype: [FileContainer]
        """
        query_parameters = {}
        if scope is not None:
            query_parameters['scope'] = self._serialize.query('scope', scope, 'str')
        if artifact_uris is not None:
            query_parameters['artifactUris'] = self._serialize.query('artifact_uris', artifact_uris, 'str')
        response = self._send(http_method='GET',
                              location_id='e4f5c81e-e250-447b-9fef-bd48471bea5e',
                              version='4.0-preview.4',
                              query_parameters=query_parameters)
        return self._deserialize('[FileContainer]', self._unwrap_collection(response))

    def get_items(self, container_id, scope=None, item_path=None, metadata=None, format=None, download_file_name=None, include_download_tickets=None, is_shallow=None):
        """GetItems.
        [Preview API]
        :param long container_id:
        :param str scope:
        :param str item_path:
        :param bool metadata:
        :param str format:
        :param str download_file_name:
        :param bool include_download_tickets:
        :param bool is_shallow:
        :rtype: [FileContainerItem]
        """
        route_values = {}
        if container_id is not None:
            route_values['containerId'] = self._serialize.url('container_id', container_id, 'long')
        query_parameters = {}
        if scope is not None:
            query_parameters['scope'] = self._serialize.query('scope', scope, 'str')
        if item_path is not None:
            query_parameters['itemPath'] = self._serialize.query('item_path', item_path, 'str')
        if metadata is not None:
            query_parameters['metadata'] = self._serialize.query('metadata', metadata, 'bool')
        if format is not None:
            query_parameters['$format'] = self._serialize.query('format', format, 'str')
        if download_file_name is not None:
            query_parameters['downloadFileName'] = self._serialize.query('download_file_name', download_file_name, 'str')
        if include_download_tickets is not None:
            query_parameters['includeDownloadTickets'] = self._serialize.query('include_download_tickets', include_download_tickets, 'bool')
        if is_shallow is not None:
            query_parameters['isShallow'] = self._serialize.query('is_shallow', is_shallow, 'bool')
        response = self._send(http_method='GET',
                              location_id='e4f5c81e-e250-447b-9fef-bd48471bea5e',
                              version='4.0-preview.4',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('[FileContainerItem]', self._unwrap_collection(response))
コード例 #40
0
class CdnManagementClient(object):
    """Use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must make sure that requests made to these resources are secure.

    :ivar config: Configuration for client.
    :vartype config: CdnManagementClientConfiguration

    :ivar profiles: Profiles operations
    :vartype profiles: .operations.ProfilesOperations
    :ivar endpoints: Endpoints operations
    :vartype endpoints: .operations.EndpointsOperations
    :ivar origins: Origins operations
    :vartype origins: .operations.OriginsOperations
    :ivar custom_domains: CustomDomains operations
    :vartype custom_domains: .operations.CustomDomainsOperations
    :ivar edge_nodes: EdgeNodes operations
    :vartype edge_nodes: .operations.EdgeNodesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Azure Subscription ID.
    :type subscription_id: str
    :param api_version: Version of the API to be used with the client request.
     Current version is 2016-10-02.
    :type api_version: str
    :param accept_language: Gets or sets the preferred language for the
     response.
    :type accept_language: str
    :param long_running_operation_retry_timeout: Gets or sets the retry
     timeout in seconds for Long Running Operations. Default value is 30.
    :type long_running_operation_retry_timeout: int
    :param generate_client_request_id: When set to true a unique
     x-ms-client-request-id value is generated and included in each request.
     Default is true.
    :type generate_client_request_id: bool
    :param str base_url: Service URL
    :param str filepath: Existing config
    """

    def __init__(
        self,
        credentials,
        subscription_id,
        api_version="2016-10-02",
        accept_language="en-US",
        long_running_operation_retry_timeout=30,
        generate_client_request_id=True,
        base_url=None,
        filepath=None,
    ):

        self.config = CdnManagementClientConfiguration(
            credentials,
            subscription_id,
            api_version,
            accept_language,
            long_running_operation_retry_timeout,
            generate_client_request_id,
            base_url,
            filepath,
        )
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.profiles = ProfilesOperations(self._client, self.config, self._serialize, self._deserialize)
        self.endpoints = EndpointsOperations(self._client, self.config, self._serialize, self._deserialize)
        self.origins = OriginsOperations(self._client, self.config, self._serialize, self._deserialize)
        self.custom_domains = CustomDomainsOperations(self._client, self.config, self._serialize, self._deserialize)
        self.edge_nodes = EdgeNodesOperations(self._client, self.config, self._serialize, self._deserialize)

    def check_name_availability(self, name, custom_headers=None, raw=False, **operation_config):
        """Check the availability of a resource name. This is needed for resources
        where name is globally unique, such as a CDN endpoint.

        :param name: The resource name to validate.
        :type name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: returns the direct response alongside the
         deserialized response
        :param operation_config: :ref:`Operation configuration
         overrides<msrest:optionsforoperations>`.
        :rtype: :class:`CheckNameAvailabilityOutput
         <azure.mgmt.cdn.models.CheckNameAvailabilityOutput>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises:
         :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>`
        """
        check_name_availability_input = models.CheckNameAvailabilityInput(name=name)

        # Construct URL
        url = "/providers/Microsoft.Cdn/checkNameAvailability"

        # Construct parameters
        query_parameters = {}
        query_parameters["api-version"] = self._serialize.query(
            "self.config.api_version", self.config.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(check_name_availability_input, "CheckNameAvailabilityInput")

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

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize("CheckNameAvailabilityOutput", response)

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

        return deserialized

    def check_resource_usage(self, custom_headers=None, raw=False, **operation_config):
        """Check the quota and actual usage of the CDN profiles under the given
        subscription.

        :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>`.
        :rtype: :class:`ResourceUsagePaged
         <azure.mgmt.cdn.models.ResourceUsagePaged>`
        :raises:
         :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>`
        """

        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage"
                path_format_arguments = {
                    "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 = {}
                query_parameters["api-version"] = self._serialize.query(
                    "self.config.api_version", self.config.api_version, "str"
                )

            else:
                url = next_link
                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 and send request
            request = self._client.post(url, query_parameters)
            response = self._client.send(request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized

    def list_operations(self, custom_headers=None, raw=False, **operation_config):
        """Lists all of the available CDN REST API operations.

        :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>`.
        :rtype: :class:`OperationPaged <azure.mgmt.cdn.models.OperationPaged>`
        :raises:
         :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>`
        """

        def internal_paging(next_link=None, raw=False):

            if not next_link:
                # Construct URL
                url = "/providers/Microsoft.Cdn/operations"

                # Construct parameters
                query_parameters = {}
                query_parameters["api-version"] = self._serialize.query(
                    "self.config.api_version", self.config.api_version, "str"
                )

            else:
                url = next_link
                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 and send request
            request = self._client.get(url, query_parameters)
            response = self._client.send(request, header_parameters, **operation_config)

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

            return response

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

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

        return deserialized
コード例 #41
0
class SecurityClient(VssClient):
    """Security
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """

    def __init__(self, base_url=None, creds=None):
        super(SecurityClient, self).__init__(base_url, creds)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def remove_access_control_entries(self, security_namespace_id, token=None, descriptors=None):
        """RemoveAccessControlEntries.
        :param str security_namespace_id:
        :param str token:
        :param str descriptors:
        :rtype: bool
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if token is not None:
            query_parameters['token'] = self._serialize.query('token', token, 'str')
        if descriptors is not None:
            query_parameters['descriptors'] = self._serialize.query('descriptors', descriptors, 'str')
        response = self._send(http_method='DELETE',
                              location_id='ac08c8ff-4323-4b08-af90-bcd018d380ce',
                              version='4.0',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('bool', response)

    def set_access_control_entries(self, container, security_namespace_id):
        """SetAccessControlEntries.
        :param :class:`<object> <security.v4_0.models.object>` container:
        :param str security_namespace_id:
        :rtype: [AccessControlEntry]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        content = self._serialize.body(container, 'object')
        response = self._send(http_method='POST',
                              location_id='ac08c8ff-4323-4b08-af90-bcd018d380ce',
                              version='4.0',
                              route_values=route_values,
                              content=content,
                              returns_collection=True)
        return self._deserialize('[AccessControlEntry]', response)

    def query_access_control_lists(self, security_namespace_id, token=None, descriptors=None, include_extended_info=None, recurse=None):
        """QueryAccessControlLists.
        :param str security_namespace_id:
        :param str token:
        :param str descriptors:
        :param bool include_extended_info:
        :param bool recurse:
        :rtype: [AccessControlList]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if token is not None:
            query_parameters['token'] = self._serialize.query('token', token, 'str')
        if descriptors is not None:
            query_parameters['descriptors'] = self._serialize.query('descriptors', descriptors, 'str')
        if include_extended_info is not None:
            query_parameters['includeExtendedInfo'] = self._serialize.query('include_extended_info', include_extended_info, 'bool')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        response = self._send(http_method='GET',
                              location_id='18a2ad18-7571-46ae-bec7-0c7da1495885',
                              version='4.0',
                              route_values=route_values,
                              query_parameters=query_parameters,
                              returns_collection=True)
        return self._deserialize('[AccessControlList]', response)

    def remove_access_control_lists(self, security_namespace_id, tokens=None, recurse=None):
        """RemoveAccessControlLists.
        :param str security_namespace_id:
        :param str tokens:
        :param bool recurse:
        :rtype: bool
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if tokens is not None:
            query_parameters['tokens'] = self._serialize.query('tokens', tokens, 'str')
        if recurse is not None:
            query_parameters['recurse'] = self._serialize.query('recurse', recurse, 'bool')
        response = self._send(http_method='DELETE',
                              location_id='18a2ad18-7571-46ae-bec7-0c7da1495885',
                              version='4.0',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('bool', response)

    def set_access_control_lists(self, access_control_lists, security_namespace_id):
        """SetAccessControlLists.
        :param :class:`<VssJsonCollectionWrapper> <security.v4_0.models.VssJsonCollectionWrapper>` access_control_lists:
        :param str security_namespace_id:
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        content = self._serialize.body(access_control_lists, 'VssJsonCollectionWrapper')
        self._send(http_method='POST',
                   location_id='18a2ad18-7571-46ae-bec7-0c7da1495885',
                   version='4.0',
                   route_values=route_values,
                   content=content)

    def has_permissions_batch(self, eval_batch):
        """HasPermissionsBatch.
        Perform a batch of "has permission" checks. This methods does not aggregate the results nor does it shortcircut if one of the permissions evaluates to false.
        :param :class:`<PermissionEvaluationBatch> <security.v4_0.models.PermissionEvaluationBatch>` eval_batch:
        :rtype: :class:`<PermissionEvaluationBatch> <security.v4_0.models.PermissionEvaluationBatch>`
        """
        content = self._serialize.body(eval_batch, 'PermissionEvaluationBatch')
        response = self._send(http_method='POST',
                              location_id='cf1faa59-1b63-4448-bf04-13d981a46f5d',
                              version='4.0',
                              content=content)
        return self._deserialize('PermissionEvaluationBatch', response)

    def has_permissions(self, security_namespace_id, permissions=None, tokens=None, always_allow_administrators=None, delimiter=None):
        """HasPermissions.
        :param str security_namespace_id:
        :param int permissions:
        :param str tokens:
        :param bool always_allow_administrators:
        :param str delimiter:
        :rtype: [bool]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        if permissions is not None:
            route_values['permissions'] = self._serialize.url('permissions', permissions, 'int')
        query_parameters = {}
        if tokens is not None:
            query_parameters['tokens'] = self._serialize.query('tokens', tokens, 'str')
        if always_allow_administrators is not None:
            query_parameters['alwaysAllowAdministrators'] = self._serialize.query('always_allow_administrators', always_allow_administrators, 'bool')
        if delimiter is not None:
            query_parameters['delimiter'] = self._serialize.query('delimiter', delimiter, 'str')
        response = self._send(http_method='GET',
                              location_id='dd3b8bd6-c7fc-4cbd-929a-933d9c011c9d',
                              version='4.0',
                              route_values=route_values,
                              query_parameters=query_parameters,
                              returns_collection=True)
        return self._deserialize('[bool]', response)

    def remove_permission(self, security_namespace_id, permissions=None, token=None, descriptor=None):
        """RemovePermission.
        :param str security_namespace_id:
        :param int permissions:
        :param str token:
        :param str descriptor:
        :rtype: :class:`<AccessControlEntry> <security.v4_0.models.AccessControlEntry>`
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        if permissions is not None:
            route_values['permissions'] = self._serialize.url('permissions', permissions, 'int')
        query_parameters = {}
        if token is not None:
            query_parameters['token'] = self._serialize.query('token', token, 'str')
        if descriptor is not None:
            query_parameters['descriptor'] = self._serialize.query('descriptor', descriptor, 'str')
        response = self._send(http_method='DELETE',
                              location_id='dd3b8bd6-c7fc-4cbd-929a-933d9c011c9d',
                              version='4.0',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('AccessControlEntry', response)

    def query_security_namespaces(self, security_namespace_id, local_only=None):
        """QuerySecurityNamespaces.
        :param str security_namespace_id:
        :param bool local_only:
        :rtype: [SecurityNamespaceDescription]
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        query_parameters = {}
        if local_only is not None:
            query_parameters['localOnly'] = self._serialize.query('local_only', local_only, 'bool')
        response = self._send(http_method='GET',
                              location_id='ce7b9f95-fde9-4be8-a86d-83b366f0b87a',
                              version='4.0',
                              route_values=route_values,
                              query_parameters=query_parameters,
                              returns_collection=True)
        return self._deserialize('[SecurityNamespaceDescription]', response)

    def set_inherit_flag(self, container, security_namespace_id):
        """SetInheritFlag.
        :param :class:`<object> <security.v4_0.models.object>` container:
        :param str security_namespace_id:
        """
        route_values = {}
        if security_namespace_id is not None:
            route_values['securityNamespaceId'] = self._serialize.url('security_namespace_id', security_namespace_id, 'str')
        content = self._serialize.body(container, 'object')
        self._send(http_method='POST',
                   location_id='ce7b9f95-fde9-4be8-a86d-83b366f0b87a',
                   version='4.0',
                   route_values=route_values,
                   content=content)
コード例 #42
0
class MixedRealityClient(SDKClient):
    """Mixed Reality Client

    :ivar config: Configuration for client.
    :vartype config: MixedRealityClientConfiguration

    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.mixedreality.operations.Operations
    :ivar spatial_anchors_accounts: SpatialAnchorsAccounts operations
    :vartype spatial_anchors_accounts: azure.mgmt.mixedreality.operations.SpatialAnchorsAccountsOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Azure subscription ID.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = MixedRealityClientConfiguration(credentials, subscription_id, base_url)
        super(MixedRealityClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2019-02-28-preview'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)
        self.spatial_anchors_accounts = SpatialAnchorsAccountsOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_name_availability_local(
            self, location, name, type, custom_headers=None, raw=False, **operation_config):
        """Check Name Availability for global uniqueness.

        :param location: The location in which uniqueness will be verified.
        :type location: str
        :param name: Resource Name To Verify
        :type name: str
        :param type: Fully qualified resource type which includes provider
         namespace
        :type type: 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: CheckNameAvailabilityResponse or ClientRawResponse if
         raw=true
        :rtype: ~azure.mgmt.mixedreality.models.CheckNameAvailabilityResponse
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.mixedreality.models.ErrorResponseException>`
        """
        check_name_availability = models.CheckNameAvailabilityRequest(name=name, type=type)

        # Construct URL
        url = self.check_name_availability_local.metadata['url']
        path_format_arguments = {
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
            'location': self._serialize.url("location", location, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(check_name_availability, 'CheckNameAvailabilityRequest')

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

        deserialized = None

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

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

        return deserialized
    check_name_availability_local.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.MixedReality/locations/{location}/checkNameAvailability'}
class FeatureAvailabilityClient(Client):
    """FeatureAvailability
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(FeatureAvailabilityClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def get_all_feature_flags(self, user_email=None):
        """GetAllFeatureFlags.
        [Preview API] Retrieve a listing of all feature flags and their current states for a user
        :param str user_email: The email of the user to check
        :rtype: [FeatureFlag]
        """
        query_parameters = {}
        if user_email is not None:
            query_parameters['userEmail'] = self._serialize.query(
                'user_email', user_email, 'str')
        response = self._send(
            http_method='GET',
            location_id='3e2b80f8-9e6f-441e-8393-005610692d9c',
            version='5.0-preview.1',
            query_parameters=query_parameters)
        return self._deserialize('[FeatureFlag]',
                                 self._unwrap_collection(response))

    def get_feature_flag_by_name(self, name, check_feature_exists=None):
        """GetFeatureFlagByName.
        [Preview API] Retrieve information on a single feature flag and its current states
        :param str name: The name of the feature to retrieve
        :param bool check_feature_exists: Check if feature exists
        :rtype: :class:`<FeatureFlag> <azure.devops.v5_0.feature_availability.models.FeatureFlag>`
        """
        route_values = {}
        if name is not None:
            route_values['name'] = self._serialize.url('name', name, 'str')
        query_parameters = {}
        if check_feature_exists is not None:
            query_parameters['checkFeatureExists'] = self._serialize.query(
                'check_feature_exists', check_feature_exists, 'bool')
        response = self._send(
            http_method='GET',
            location_id='3e2b80f8-9e6f-441e-8393-005610692d9c',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('FeatureFlag', response)

    def get_feature_flag_by_name_and_user_email(self,
                                                name,
                                                user_email,
                                                check_feature_exists=None):
        """GetFeatureFlagByNameAndUserEmail.
        [Preview API] Retrieve information on a single feature flag and its current states for a user
        :param str name: The name of the feature to retrieve
        :param str user_email: The email of the user to check
        :param bool check_feature_exists: Check if feature exists
        :rtype: :class:`<FeatureFlag> <azure.devops.v5_0.feature_availability.models.FeatureFlag>`
        """
        route_values = {}
        if name is not None:
            route_values['name'] = self._serialize.url('name', name, 'str')
        query_parameters = {}
        if user_email is not None:
            query_parameters['userEmail'] = self._serialize.query(
                'user_email', user_email, 'str')
        if check_feature_exists is not None:
            query_parameters['checkFeatureExists'] = self._serialize.query(
                'check_feature_exists', check_feature_exists, 'bool')
        response = self._send(
            http_method='GET',
            location_id='3e2b80f8-9e6f-441e-8393-005610692d9c',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('FeatureFlag', response)

    def get_feature_flag_by_name_and_user_id(self,
                                             name,
                                             user_id,
                                             check_feature_exists=None):
        """GetFeatureFlagByNameAndUserId.
        [Preview API] Retrieve information on a single feature flag and its current states for a user
        :param str name: The name of the feature to retrieve
        :param str user_id: The id of the user to check
        :param bool check_feature_exists: Check if feature exists
        :rtype: :class:`<FeatureFlag> <azure.devops.v5_0.feature_availability.models.FeatureFlag>`
        """
        route_values = {}
        if name is not None:
            route_values['name'] = self._serialize.url('name', name, 'str')
        query_parameters = {}
        if user_id is not None:
            query_parameters['userId'] = self._serialize.query(
                'user_id', user_id, 'str')
        if check_feature_exists is not None:
            query_parameters['checkFeatureExists'] = self._serialize.query(
                'check_feature_exists', check_feature_exists, 'bool')
        response = self._send(
            http_method='GET',
            location_id='3e2b80f8-9e6f-441e-8393-005610692d9c',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('FeatureFlag', response)

    def update_feature_flag(self,
                            state,
                            name,
                            user_email=None,
                            check_feature_exists=None,
                            set_at_application_level_also=None):
        """UpdateFeatureFlag.
        [Preview API] Change the state of an individual feature flag for a name
        :param :class:`<FeatureFlagPatch> <azure.devops.v5_0.feature_availability.models.FeatureFlagPatch>` state: State that should be set
        :param str name: The name of the feature to change
        :param str user_email:
        :param bool check_feature_exists: Checks if the feature exists before setting the state
        :param bool set_at_application_level_also:
        :rtype: :class:`<FeatureFlag> <azure.devops.v5_0.feature_availability.models.FeatureFlag>`
        """
        route_values = {}
        if name is not None:
            route_values['name'] = self._serialize.url('name', name, 'str')
        query_parameters = {}
        if user_email is not None:
            query_parameters['userEmail'] = self._serialize.query(
                'user_email', user_email, 'str')
        if check_feature_exists is not None:
            query_parameters['checkFeatureExists'] = self._serialize.query(
                'check_feature_exists', check_feature_exists, 'bool')
        if set_at_application_level_also is not None:
            query_parameters[
                'setAtApplicationLevelAlso'] = self._serialize.query(
                    'set_at_application_level_also',
                    set_at_application_level_also, 'bool')
        content = self._serialize.body(state, 'FeatureFlagPatch')
        response = self._send(
            http_method='PATCH',
            location_id='3e2b80f8-9e6f-441e-8393-005610692d9c',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters,
            content=content)
        return self._deserialize('FeatureFlag', response)
コード例 #44
0
class EventGridClient(object):
    """EventGrid Client

    :ivar config: Configuration for client.
    :vartype config: EventGridClientConfiguration

    :param credentials: Subscription credentials which uniquely identify
     client subscription.
    :type credentials: None
    """

    def __init__(
            self, credentials):

        self.config = EventGridClientConfiguration(credentials)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2018-01-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def publish_events(
            self, topic_hostname, events, custom_headers=None, raw=False, **operation_config):
        """Publishes a batch of events to an Azure Event Grid topic.

        :param topic_hostname: The host name of the topic, e.g.
         topic1.westus2-1.eventgrid.azure.net
        :type topic_hostname: str
        :param events: An array of events to be published to Event Grid.
        :type events: list[~azure.eventgrid.models.EventGridEvent]
        :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:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        # Construct URL
        url = '/api/events'
        path_format_arguments = {
            'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True)
        }
        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 custom_headers:
            header_parameters.update(custom_headers)

        # Construct body
        body_content = self._serialize.body(events, '[EventGridEvent]')

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

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response
コード例 #45
0
class CoreClient(Client):
    """Core
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """
    def __init__(self, base_url=None, creds=None):
        super(CoreClient, self).__init__(base_url, creds)
        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = '79134c72-4a58-4b42-976c-04e7115f32bf'

    def create_connected_service(self, connected_service_creation_data,
                                 project_id):
        """CreateConnectedService.
        [Preview API]
        :param :class:`<WebApiConnectedServiceDetails> <azure.devops.v5_0.core.models.WebApiConnectedServiceDetails>` connected_service_creation_data:
        :param str project_id:
        :rtype: :class:`<WebApiConnectedService> <azure.devops.v5_0.core.models.WebApiConnectedService>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(connected_service_creation_data,
                                       'WebApiConnectedServiceDetails')
        response = self._send(
            http_method='POST',
            location_id='b4f70219-e18b-42c5-abe3-98b07d35525e',
            version='5.0-preview.1',
            route_values=route_values,
            content=content)
        return self._deserialize('WebApiConnectedService', response)

    def get_connected_service_details(self, project_id, name):
        """GetConnectedServiceDetails.
        [Preview API]
        :param str project_id:
        :param str name:
        :rtype: :class:`<WebApiConnectedServiceDetails> <azure.devops.v5_0.core.models.WebApiConnectedServiceDetails>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if name is not None:
            route_values['name'] = self._serialize.url('name', name, 'str')
        response = self._send(
            http_method='GET',
            location_id='b4f70219-e18b-42c5-abe3-98b07d35525e',
            version='5.0-preview.1',
            route_values=route_values)
        return self._deserialize('WebApiConnectedServiceDetails', response)

    def get_connected_services(self, project_id, kind=None):
        """GetConnectedServices.
        [Preview API]
        :param str project_id:
        :param str kind:
        :rtype: [WebApiConnectedService]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if kind is not None:
            query_parameters['kind'] = self._serialize.query(
                'kind', kind, 'str')
        response = self._send(
            http_method='GET',
            location_id='b4f70219-e18b-42c5-abe3-98b07d35525e',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[WebApiConnectedService]',
                                 self._unwrap_collection(response))

    def get_team_members_with_extended_properties(self,
                                                  project_id,
                                                  team_id,
                                                  top=None,
                                                  skip=None):
        """GetTeamMembersWithExtendedProperties.
        Get a list of members for a specific team.
        :param str project_id: The name or ID (GUID) of the team project the team belongs to.
        :param str team_id: The name or ID (GUID) of the team .
        :param int top:
        :param int skip:
        :rtype: [TeamMember]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='294c494c-2600-4d7e-b76c-3dd50c3c95be',
            version='5.0',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[TeamMember]',
                                 self._unwrap_collection(response))

    def get_process_by_id(self, process_id):
        """GetProcessById.
        Get a process by ID.
        :param str process_id: ID for a process.
        :rtype: :class:`<Process> <azure.devops.v5_0.core.models.Process>`
        """
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url(
                'process_id', process_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='93878975-88c5-4e6a-8abb-7ddd77a8a7d8',
            version='5.0',
            route_values=route_values)
        return self._deserialize('Process', response)

    def get_processes(self):
        """GetProcesses.
        Get a list of processes.
        :rtype: [Process]
        """
        response = self._send(
            http_method='GET',
            location_id='93878975-88c5-4e6a-8abb-7ddd77a8a7d8',
            version='5.0')
        return self._deserialize('[Process]',
                                 self._unwrap_collection(response))

    def get_project_collection(self, collection_id):
        """GetProjectCollection.
        Get project collection with the specified id or name.
        :param str collection_id:
        :rtype: :class:`<TeamProjectCollection> <azure.devops.v5_0.core.models.TeamProjectCollection>`
        """
        route_values = {}
        if collection_id is not None:
            route_values['collectionId'] = self._serialize.url(
                'collection_id', collection_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='8031090f-ef1d-4af6-85fc-698cd75d42bf',
            version='5.0',
            route_values=route_values)
        return self._deserialize('TeamProjectCollection', response)

    def get_project_collections(self, top=None, skip=None):
        """GetProjectCollections.
        Get project collection references for this application.
        :param int top:
        :param int skip:
        :rtype: [TeamProjectCollectionReference]
        """
        query_parameters = {}
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='8031090f-ef1d-4af6-85fc-698cd75d42bf',
            version='5.0',
            query_parameters=query_parameters)
        return self._deserialize('[TeamProjectCollectionReference]',
                                 self._unwrap_collection(response))

    def get_project(self,
                    project_id,
                    include_capabilities=None,
                    include_history=None):
        """GetProject.
        Get project with the specified id or name, optionally including capabilities.
        :param str project_id:
        :param bool include_capabilities: Include capabilities (such as source control) in the team project result (default: false).
        :param bool include_history: Search within renamed projects (that had such name in the past).
        :rtype: :class:`<TeamProject> <azure.devops.v5_0.core.models.TeamProject>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if include_capabilities is not None:
            query_parameters['includeCapabilities'] = self._serialize.query(
                'include_capabilities', include_capabilities, 'bool')
        if include_history is not None:
            query_parameters['includeHistory'] = self._serialize.query(
                'include_history', include_history, 'bool')
        response = self._send(
            http_method='GET',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='5.0',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('TeamProject', response)

    def get_projects(self,
                     state_filter=None,
                     top=None,
                     skip=None,
                     continuation_token=None,
                     get_default_team_image_url=None):
        """GetProjects.
        Get all projects in the organization that the authenticated user has access to.
        :param str state_filter: Filter on team projects in a specific team project state (default: WellFormed).
        :param int top:
        :param int skip:
        :param str continuation_token:
        :param bool get_default_team_image_url:
        :rtype: [TeamProjectReference]
        """
        query_parameters = {}
        if state_filter is not None:
            query_parameters['stateFilter'] = self._serialize.query(
                'state_filter', state_filter, 'str')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        if continuation_token is not None:
            query_parameters['continuationToken'] = self._serialize.query(
                'continuation_token', continuation_token, 'str')
        if get_default_team_image_url is not None:
            query_parameters['getDefaultTeamImageUrl'] = self._serialize.query(
                'get_default_team_image_url', get_default_team_image_url,
                'bool')
        response = self._send(
            http_method='GET',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='5.0',
            query_parameters=query_parameters)
        return self._deserialize('[TeamProjectReference]',
                                 self._unwrap_collection(response))

    def queue_create_project(self, project_to_create):
        """QueueCreateProject.
        Queues a project to be created. Use the [GetOperation](../../operations/operations/get) to periodically check for create project status.
        :param :class:`<TeamProject> <azure.devops.v5_0.core.models.TeamProject>` project_to_create: The project to create.
        :rtype: :class:`<OperationReference> <azure.devops.v5_0.core.models.OperationReference>`
        """
        content = self._serialize.body(project_to_create, 'TeamProject')
        response = self._send(
            http_method='POST',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='5.0',
            content=content)
        return self._deserialize('OperationReference', response)

    def queue_delete_project(self, project_id):
        """QueueDeleteProject.
        Queues a project to be deleted. Use the [GetOperation](../../operations/operations/get) to periodically check for delete project status.
        :param str project_id: The project id of the project to delete.
        :rtype: :class:`<OperationReference> <azure.devops.v5_0.core.models.OperationReference>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        response = self._send(
            http_method='DELETE',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='5.0',
            route_values=route_values)
        return self._deserialize('OperationReference', response)

    def update_project(self, project_update, project_id):
        """UpdateProject.
        Update an existing project's name, abbreviation, or description.
        :param :class:`<TeamProject> <azure.devops.v5_0.core.models.TeamProject>` project_update: The updates for the project.
        :param str project_id: The project id of the project to update.
        :rtype: :class:`<OperationReference> <azure.devops.v5_0.core.models.OperationReference>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(project_update, 'TeamProject')
        response = self._send(
            http_method='PATCH',
            location_id='603fe2ac-9723-48b9-88ad-09305aa6c6e1',
            version='5.0',
            route_values=route_values,
            content=content)
        return self._deserialize('OperationReference', response)

    def get_project_properties(self, project_id, keys=None):
        """GetProjectProperties.
        [Preview API] Get a collection of team project properties.
        :param str project_id: The team project ID.
        :param [str] keys: A comma-delimited string of team project property names. Wildcard characters ("?" and "*") are supported. If no key is specified, all properties will be returned.
        :rtype: [ProjectProperty]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if keys is not None:
            keys = ",".join(keys)
            query_parameters['keys'] = self._serialize.query(
                'keys', keys, 'str')
        response = self._send(
            http_method='GET',
            location_id='4976a71a-4487-49aa-8aab-a1eda469037a',
            version='5.0-preview.1',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[ProjectProperty]',
                                 self._unwrap_collection(response))

    def set_project_properties(self, project_id, patch_document):
        """SetProjectProperties.
        [Preview API] Create, update, and delete team project properties.
        :param str project_id: The team project ID.
        :param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.core.models.[JsonPatchOperation]>` patch_document: A JSON Patch document that represents an array of property operations. See RFC 6902 for more details on JSON Patch. The accepted operation verbs are Add and Remove, where Add is used for both creating and updating properties. The path consists of a forward slash and a property name.
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(patch_document, '[JsonPatchOperation]')
        self._send(http_method='PATCH',
                   location_id='4976a71a-4487-49aa-8aab-a1eda469037a',
                   version='5.0-preview.1',
                   route_values=route_values,
                   content=content,
                   media_type='application/json-patch+json')

    def create_or_update_proxy(self, proxy):
        """CreateOrUpdateProxy.
        [Preview API]
        :param :class:`<Proxy> <azure.devops.v5_0.core.models.Proxy>` proxy:
        :rtype: :class:`<Proxy> <azure.devops.v5_0.core.models.Proxy>`
        """
        content = self._serialize.body(proxy, 'Proxy')
        response = self._send(
            http_method='PUT',
            location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
            version='5.0-preview.2',
            content=content)
        return self._deserialize('Proxy', response)

    def delete_proxy(self, proxy_url, site=None):
        """DeleteProxy.
        [Preview API]
        :param str proxy_url:
        :param str site:
        """
        query_parameters = {}
        if proxy_url is not None:
            query_parameters['proxyUrl'] = self._serialize.query(
                'proxy_url', proxy_url, 'str')
        if site is not None:
            query_parameters['site'] = self._serialize.query(
                'site', site, 'str')
        self._send(http_method='DELETE',
                   location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
                   version='5.0-preview.2',
                   query_parameters=query_parameters)

    def get_proxies(self, proxy_url=None):
        """GetProxies.
        [Preview API]
        :param str proxy_url:
        :rtype: [Proxy]
        """
        query_parameters = {}
        if proxy_url is not None:
            query_parameters['proxyUrl'] = self._serialize.query(
                'proxy_url', proxy_url, 'str')
        response = self._send(
            http_method='GET',
            location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
            version='5.0-preview.2',
            query_parameters=query_parameters)
        return self._deserialize('[Proxy]', self._unwrap_collection(response))

    def create_team(self, team, project_id):
        """CreateTeam.
        Create a team in a team project.
        :param :class:`<WebApiTeam> <azure.devops.v5_0.core.models.WebApiTeam>` team: The team data used to create the team.
        :param str project_id: The name or ID (GUID) of the team project in which to create the team.
        :rtype: :class:`<WebApiTeam> <azure.devops.v5_0.core.models.WebApiTeam>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        content = self._serialize.body(team, 'WebApiTeam')
        response = self._send(
            http_method='POST',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='5.0',
            route_values=route_values,
            content=content)
        return self._deserialize('WebApiTeam', response)

    def delete_team(self, project_id, team_id):
        """DeleteTeam.
        Delete a team.
        :param str project_id: The name or ID (GUID) of the team project containing the team to delete.
        :param str team_id: The name of ID of the team to delete.
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        self._send(http_method='DELETE',
                   location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
                   version='5.0',
                   route_values=route_values)

    def get_team(self, project_id, team_id):
        """GetTeam.
        Get a specific team.
        :param str project_id: The name or ID (GUID) of the team project containing the team.
        :param str team_id: The name or ID (GUID) of the team.
        :rtype: :class:`<WebApiTeam> <azure.devops.v5_0.core.models.WebApiTeam>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        response = self._send(
            http_method='GET',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='5.0',
            route_values=route_values)
        return self._deserialize('WebApiTeam', response)

    def get_teams(self, project_id, mine=None, top=None, skip=None):
        """GetTeams.
        Get a list of teams.
        :param str project_id:
        :param bool mine: If true return all the teams requesting user is member, otherwise return all the teams user has read access
        :param int top: Maximum number of teams to return.
        :param int skip: Number of teams to skip.
        :rtype: [WebApiTeam]
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        query_parameters = {}
        if mine is not None:
            query_parameters['$mine'] = self._serialize.query(
                'mine', mine, 'bool')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='5.0',
            route_values=route_values,
            query_parameters=query_parameters)
        return self._deserialize('[WebApiTeam]',
                                 self._unwrap_collection(response))

    def update_team(self, team_data, project_id, team_id):
        """UpdateTeam.
        Update a team's name and/or description.
        :param :class:`<WebApiTeam> <azure.devops.v5_0.core.models.WebApiTeam>` team_data:
        :param str project_id: The name or ID (GUID) of the team project containing the team to update.
        :param str team_id: The name of ID of the team to update.
        :rtype: :class:`<WebApiTeam> <azure.devops.v5_0.core.models.WebApiTeam>`
        """
        route_values = {}
        if project_id is not None:
            route_values['projectId'] = self._serialize.url(
                'project_id', project_id, 'str')
        if team_id is not None:
            route_values['teamId'] = self._serialize.url(
                'team_id', team_id, 'str')
        content = self._serialize.body(team_data, 'WebApiTeam')
        response = self._send(
            http_method='PATCH',
            location_id='d30a3dd1-f8ba-442a-b86a-bd0c0c383e59',
            version='5.0',
            route_values=route_values,
            content=content)
        return self._deserialize('WebApiTeam', response)

    def get_all_teams(self, mine=None, top=None, skip=None):
        """GetAllTeams.
        [Preview API] Get a list of all teams.
        :param bool mine: If true return all the teams requesting user is member, otherwise return all the teams user has read access
        :param int top: Maximum number of teams to return.
        :param int skip: Number of teams to skip.
        :rtype: [WebApiTeam]
        """
        query_parameters = {}
        if mine is not None:
            query_parameters['$mine'] = self._serialize.query(
                'mine', mine, 'bool')
        if top is not None:
            query_parameters['$top'] = self._serialize.query('top', top, 'int')
        if skip is not None:
            query_parameters['$skip'] = self._serialize.query(
                'skip', skip, 'int')
        response = self._send(
            http_method='GET',
            location_id='7a4d9ee9-3433-4347-b47a-7a80f1cf307e',
            version='5.0-preview.2',
            query_parameters=query_parameters)
        return self._deserialize('[WebApiTeam]',
                                 self._unwrap_collection(response))
コード例 #46
0
class NetworkManagementClient(SDKClient):
    """Network Client

    :ivar config: Configuration for client.
    :vartype config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: azure.mgmt.network.v2018_08_01.operations.ApplicationGatewaysOperations
    :ivar application_security_groups: ApplicationSecurityGroups operations
    :vartype application_security_groups: azure.mgmt.network.v2018_08_01.operations.ApplicationSecurityGroupsOperations
    :ivar available_delegations: AvailableDelegations operations
    :vartype available_delegations: azure.mgmt.network.v2018_08_01.operations.AvailableDelegationsOperations
    :ivar available_resource_group_delegations: AvailableResourceGroupDelegations operations
    :vartype available_resource_group_delegations: azure.mgmt.network.v2018_08_01.operations.AvailableResourceGroupDelegationsOperations
    :ivar azure_firewalls: AzureFirewalls operations
    :vartype azure_firewalls: azure.mgmt.network.v2018_08_01.operations.AzureFirewallsOperations
    :ivar azure_firewall_fqdn_tags: AzureFirewallFqdnTags operations
    :vartype azure_firewall_fqdn_tags: azure.mgmt.network.v2018_08_01.operations.AzureFirewallFqdnTagsOperations
    :ivar ddos_protection_plans: DdosProtectionPlans operations
    :vartype ddos_protection_plans: azure.mgmt.network.v2018_08_01.operations.DdosProtectionPlansOperations
    :ivar available_endpoint_services: AvailableEndpointServices operations
    :vartype available_endpoint_services: azure.mgmt.network.v2018_08_01.operations.AvailableEndpointServicesOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: azure.mgmt.network.v2018_08_01.operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: azure.mgmt.network.v2018_08_01.operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuit_connections: ExpressRouteCircuitConnections operations
    :vartype express_route_circuit_connections: azure.mgmt.network.v2018_08_01.operations.ExpressRouteCircuitConnectionsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: azure.mgmt.network.v2018_08_01.operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: azure.mgmt.network.v2018_08_01.operations.ExpressRouteServiceProvidersOperations
    :ivar express_route_cross_connections: ExpressRouteCrossConnections operations
    :vartype express_route_cross_connections: azure.mgmt.network.v2018_08_01.operations.ExpressRouteCrossConnectionsOperations
    :ivar express_route_cross_connection_peerings: ExpressRouteCrossConnectionPeerings operations
    :vartype express_route_cross_connection_peerings: azure.mgmt.network.v2018_08_01.operations.ExpressRouteCrossConnectionPeeringsOperations
    :ivar express_route_gateways: ExpressRouteGateways operations
    :vartype express_route_gateways: azure.mgmt.network.v2018_08_01.operations.ExpressRouteGatewaysOperations
    :ivar express_route_connections: ExpressRouteConnections operations
    :vartype express_route_connections: azure.mgmt.network.v2018_08_01.operations.ExpressRouteConnectionsOperations
    :ivar express_route_ports_locations: ExpressRoutePortsLocations operations
    :vartype express_route_ports_locations: azure.mgmt.network.v2018_08_01.operations.ExpressRoutePortsLocationsOperations
    :ivar express_route_ports: ExpressRoutePorts operations
    :vartype express_route_ports: azure.mgmt.network.v2018_08_01.operations.ExpressRoutePortsOperations
    :ivar express_route_links: ExpressRouteLinks operations
    :vartype express_route_links: azure.mgmt.network.v2018_08_01.operations.ExpressRouteLinksOperations
    :ivar interface_endpoints: InterfaceEndpoints operations
    :vartype interface_endpoints: azure.mgmt.network.v2018_08_01.operations.InterfaceEndpointsOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: azure.mgmt.network.v2018_08_01.operations.LoadBalancersOperations
    :ivar load_balancer_backend_address_pools: LoadBalancerBackendAddressPools operations
    :vartype load_balancer_backend_address_pools: azure.mgmt.network.v2018_08_01.operations.LoadBalancerBackendAddressPoolsOperations
    :ivar load_balancer_frontend_ip_configurations: LoadBalancerFrontendIPConfigurations operations
    :vartype load_balancer_frontend_ip_configurations: azure.mgmt.network.v2018_08_01.operations.LoadBalancerFrontendIPConfigurationsOperations
    :ivar inbound_nat_rules: InboundNatRules operations
    :vartype inbound_nat_rules: azure.mgmt.network.v2018_08_01.operations.InboundNatRulesOperations
    :ivar load_balancer_load_balancing_rules: LoadBalancerLoadBalancingRules operations
    :vartype load_balancer_load_balancing_rules: azure.mgmt.network.v2018_08_01.operations.LoadBalancerLoadBalancingRulesOperations
    :ivar load_balancer_network_interfaces: LoadBalancerNetworkInterfaces operations
    :vartype load_balancer_network_interfaces: azure.mgmt.network.v2018_08_01.operations.LoadBalancerNetworkInterfacesOperations
    :ivar load_balancer_probes: LoadBalancerProbes operations
    :vartype load_balancer_probes: azure.mgmt.network.v2018_08_01.operations.LoadBalancerProbesOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: azure.mgmt.network.v2018_08_01.operations.NetworkInterfacesOperations
    :ivar network_interface_ip_configurations: NetworkInterfaceIPConfigurations operations
    :vartype network_interface_ip_configurations: azure.mgmt.network.v2018_08_01.operations.NetworkInterfaceIPConfigurationsOperations
    :ivar network_interface_load_balancers: NetworkInterfaceLoadBalancers operations
    :vartype network_interface_load_balancers: azure.mgmt.network.v2018_08_01.operations.NetworkInterfaceLoadBalancersOperations
    :ivar network_interface_tap_configurations: NetworkInterfaceTapConfigurations operations
    :vartype network_interface_tap_configurations: azure.mgmt.network.v2018_08_01.operations.NetworkInterfaceTapConfigurationsOperations
    :ivar network_profiles: NetworkProfiles operations
    :vartype network_profiles: azure.mgmt.network.v2018_08_01.operations.NetworkProfilesOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: azure.mgmt.network.v2018_08_01.operations.NetworkSecurityGroupsOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: azure.mgmt.network.v2018_08_01.operations.SecurityRulesOperations
    :ivar default_security_rules: DefaultSecurityRules operations
    :vartype default_security_rules: azure.mgmt.network.v2018_08_01.operations.DefaultSecurityRulesOperations
    :ivar network_watchers: NetworkWatchers operations
    :vartype network_watchers: azure.mgmt.network.v2018_08_01.operations.NetworkWatchersOperations
    :ivar packet_captures: PacketCaptures operations
    :vartype packet_captures: azure.mgmt.network.v2018_08_01.operations.PacketCapturesOperations
    :ivar connection_monitors: ConnectionMonitors operations
    :vartype connection_monitors: azure.mgmt.network.v2018_08_01.operations.ConnectionMonitorsOperations
    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.network.v2018_08_01.operations.Operations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: azure.mgmt.network.v2018_08_01.operations.PublicIPAddressesOperations
    :ivar public_ip_prefixes: PublicIPPrefixes operations
    :vartype public_ip_prefixes: azure.mgmt.network.v2018_08_01.operations.PublicIPPrefixesOperations
    :ivar route_filters: RouteFilters operations
    :vartype route_filters: azure.mgmt.network.v2018_08_01.operations.RouteFiltersOperations
    :ivar route_filter_rules: RouteFilterRules operations
    :vartype route_filter_rules: azure.mgmt.network.v2018_08_01.operations.RouteFilterRulesOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: azure.mgmt.network.v2018_08_01.operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: azure.mgmt.network.v2018_08_01.operations.RoutesOperations
    :ivar bgp_service_communities: BgpServiceCommunities operations
    :vartype bgp_service_communities: azure.mgmt.network.v2018_08_01.operations.BgpServiceCommunitiesOperations
    :ivar service_endpoint_policies: ServiceEndpointPolicies operations
    :vartype service_endpoint_policies: azure.mgmt.network.v2018_08_01.operations.ServiceEndpointPoliciesOperations
    :ivar service_endpoint_policy_definitions: ServiceEndpointPolicyDefinitions operations
    :vartype service_endpoint_policy_definitions: azure.mgmt.network.v2018_08_01.operations.ServiceEndpointPolicyDefinitionsOperations
    :ivar usages: Usages operations
    :vartype usages: azure.mgmt.network.v2018_08_01.operations.UsagesOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: azure.mgmt.network.v2018_08_01.operations.VirtualNetworksOperations
    :ivar subnets: Subnets operations
    :vartype subnets: azure.mgmt.network.v2018_08_01.operations.SubnetsOperations
    :ivar virtual_network_peerings: VirtualNetworkPeerings operations
    :vartype virtual_network_peerings: azure.mgmt.network.v2018_08_01.operations.VirtualNetworkPeeringsOperations
    :ivar virtual_network_taps: VirtualNetworkTaps operations
    :vartype virtual_network_taps: azure.mgmt.network.v2018_08_01.operations.VirtualNetworkTapsOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: azure.mgmt.network.v2018_08_01.operations.VirtualNetworkGatewaysOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: azure.mgmt.network.v2018_08_01.operations.VirtualNetworkGatewayConnectionsOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: azure.mgmt.network.v2018_08_01.operations.LocalNetworkGatewaysOperations
    :ivar virtual_wans: VirtualWans operations
    :vartype virtual_wans: azure.mgmt.network.v2018_08_01.operations.VirtualWansOperations
    :ivar vpn_sites: VpnSites operations
    :vartype vpn_sites: azure.mgmt.network.v2018_08_01.operations.VpnSitesOperations
    :ivar vpn_sites_configuration: VpnSitesConfiguration operations
    :vartype vpn_sites_configuration: azure.mgmt.network.v2018_08_01.operations.VpnSitesConfigurationOperations
    :ivar virtual_hubs: VirtualHubs operations
    :vartype virtual_hubs: azure.mgmt.network.v2018_08_01.operations.VirtualHubsOperations
    :ivar hub_virtual_network_connections: HubVirtualNetworkConnections operations
    :vartype hub_virtual_network_connections: azure.mgmt.network.v2018_08_01.operations.HubVirtualNetworkConnectionsOperations
    :ivar vpn_gateways: VpnGateways operations
    :vartype vpn_gateways: azure.mgmt.network.v2018_08_01.operations.VpnGatewaysOperations
    :ivar vpn_connections: VpnConnections operations
    :vartype vpn_connections: azure.mgmt.network.v2018_08_01.operations.VpnConnectionsOperations
    :ivar p2s_vpn_server_configurations: P2sVpnServerConfigurations operations
    :vartype p2s_vpn_server_configurations: azure.mgmt.network.v2018_08_01.operations.P2sVpnServerConfigurationsOperations
    :ivar p2s_vpn_gateways: P2sVpnGateways operations
    :vartype p2s_vpn_gateways: azure.mgmt.network.v2018_08_01.operations.P2sVpnGatewaysOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription credentials which uniquely
     identify the Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = NetworkManagementClientConfiguration(credentials, subscription_id, base_url)
        super(NetworkManagementClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.application_security_groups = ApplicationSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_delegations = AvailableDelegationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_resource_group_delegations = AvailableResourceGroupDelegationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.azure_firewalls = AzureFirewallsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.azure_firewall_fqdn_tags = AzureFirewallFqdnTagsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.ddos_protection_plans = DdosProtectionPlansOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_endpoint_services = AvailableEndpointServicesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_connections = ExpressRouteCircuitConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_cross_connections = ExpressRouteCrossConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_cross_connection_peerings = ExpressRouteCrossConnectionPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_gateways = ExpressRouteGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_connections = ExpressRouteConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_ports_locations = ExpressRoutePortsLocationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_ports = ExpressRoutePortsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_links = ExpressRouteLinksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.interface_endpoints = InterfaceEndpointsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_backend_address_pools = LoadBalancerBackendAddressPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_frontend_ip_configurations = LoadBalancerFrontendIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.inbound_nat_rules = InboundNatRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_load_balancing_rules = LoadBalancerLoadBalancingRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_network_interfaces = LoadBalancerNetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_probes = LoadBalancerProbesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_ip_configurations = NetworkInterfaceIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_load_balancers = NetworkInterfaceLoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_tap_configurations = NetworkInterfaceTapConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_profiles = NetworkProfilesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.default_security_rules = DefaultSecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_watchers = NetworkWatchersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.packet_captures = PacketCapturesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.connection_monitors = ConnectionMonitorsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_prefixes = PublicIPPrefixesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_filters = RouteFiltersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_filter_rules = RouteFilterRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.routes = RoutesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.bgp_service_communities = BgpServiceCommunitiesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.service_endpoint_policies = ServiceEndpointPoliciesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.service_endpoint_policy_definitions = ServiceEndpointPolicyDefinitionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_peerings = VirtualNetworkPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_taps = VirtualNetworkTapsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_wans = VirtualWansOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.vpn_sites = VpnSitesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.vpn_sites_configuration = VpnSitesConfigurationOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_hubs = VirtualHubsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.hub_virtual_network_connections = HubVirtualNetworkConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.vpn_gateways = VpnGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.vpn_connections = VpnConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.p2s_vpn_server_configurations = P2sVpnServerConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.p2s_vpn_gateways = P2sVpnGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(
            self, location, domain_name_label, custom_headers=None, raw=False, **operation_config):
        """Checks whether a domain name in the cloudapp.azure.com zone is
        available for use.

        :param location: The location of the domain name.
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: 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: DnsNameAvailabilityResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.network.v2018_08_01.models.DnsNameAvailabilityResult or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2018-08-01"

        # Construct URL
        url = self.check_dns_name_availability.metadata['url']
        path_format_arguments = {
            'location': self._serialize.url("location", location, '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 = {}
        query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
    check_dns_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'}

    def supported_security_providers(
            self, resource_group_name, virtual_wan_name, custom_headers=None, raw=False, **operation_config):
        """Gives the supported security providers for the virtual wan.

        :param resource_group_name: The resource group name.
        :type resource_group_name: str
        :param virtual_wan_name: The name of the VirtualWAN for which
         supported security providers are needed.
        :type virtual_wan_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: VirtualWanSecurityProviders or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.network.v2018_08_01.models.VirtualWanSecurityProviders or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorException<azure.mgmt.network.v2018_08_01.models.ErrorException>`
        """
        api_version = "2018-08-01"

        # Construct URL
        url = self.supported_security_providers.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'),
            'virtualWANName': self._serialize.url("virtual_wan_name", virtual_wan_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

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

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

        deserialized = None

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

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

        return deserialized
    supported_security_providers.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/supportedSecurityProviders'}
コード例 #47
0
class AutoRestValidationTest(object):
    """Test Infrastructure for AutoRest. No server backend exists for these tests.

    :ivar config: Configuration for client.
    :vartype config: AutoRestValidationTestConfiguration

    :param subscription_id: Subscription ID.
    :type subscription_id: str
    :param api_version: Required string following pattern \\d{2}-\\d{2}-\\d{4}
    :type api_version: str
    :param str base_url: Service URL
    :param str filepath: Existing config
    """
    def __init__(self,
                 subscription_id,
                 api_version,
                 base_url=None,
                 filepath=None):

        self.config = AutoRestValidationTestConfiguration(
            subscription_id, api_version, base_url, filepath)
        self._client = ServiceClient(None, self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    def validation_of_method_parameters(self,
                                        resource_group_name,
                                        id,
                                        custom_headers=None,
                                        raw=False,
                                        **operation_config):
        """Validates input parameters on the method. See swagger for details.

        :param resource_group_name: Required string between 3 and 10 chars
         with pattern [a-zA-Z0-9]+.
        :type resource_group_name: str
        :param id: Required int multiple of 10 from 100 to 1000.
        :type id: 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>`.
        :rtype: :class:`Product
         <Fixtures.AcceptanceTestsValidation.models.Product>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
        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',
                                max_length=10,
                                min_length=3,
                                pattern='[a-zA-Z0-9]+'),
            'id':
            self._serialize.url("id",
                                id,
                                'int',
                                maximum=1000,
                                minimum=100,
                                multiple=10)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['apiVersion'] = self._serialize.query(
            "self.config.api_version",
            self.config.api_version,
            'str',
            pattern='\d{2}-\d{2}-\d{4}')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized

    def validation_of_body(self,
                           resource_group_name,
                           id,
                           body=None,
                           custom_headers=None,
                           raw=False,
                           **operation_config):
        """Validates body parameters on the method. See swagger for details.

        :param resource_group_name: Required string between 3 and 10 chars
         with pattern [a-zA-Z0-9]+.
        :type resource_group_name: str
        :param id: Required int multiple of 10 from 100 to 1000.
        :type id: int
        :param body:
        :type body: :class:`Product
         <Fixtures.AcceptanceTestsValidation.models.Product>`
        :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>`.
        :rtype: :class:`Product
         <Fixtures.AcceptanceTestsValidation.models.Product>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        # Construct URL
        url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
        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',
                                max_length=10,
                                min_length=3,
                                pattern='[a-zA-Z0-9]+'),
            'id':
            self._serialize.url("id",
                                id,
                                'int',
                                maximum=1000,
                                minimum=100,
                                multiple=10)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['apiVersion'] = self._serialize.query(
            "self.config.api_version",
            self.config.api_version,
            'str',
            pattern='\d{2}-\d{2}-\d{4}')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Product')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized

    def get_with_constant_in_path(self,
                                  custom_headers=None,
                                  raw=False,
                                  **operation_config):
        """

        :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>`.
        :rtype: None
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        constant_param = "constant"

        # Construct URL
        url = '/validation/constantsInPath/{constantParam}/value'
        path_format_arguments = {
            'constantParam':
            self._serialize.url("constant_param", constant_param, '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)

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

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

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

    def post_with_constant_in_body(self,
                                   body=None,
                                   custom_headers=None,
                                   raw=False,
                                   **operation_config):
        """

        :param body:
        :type body: :class:`Product
         <Fixtures.AcceptanceTestsValidation.models.Product>`
        :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>`.
        :rtype: :class:`Product
         <Fixtures.AcceptanceTestsValidation.models.Product>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        """
        constant_param = "constant"

        # Construct URL
        url = '/validation/constantsInPath/{constantParam}/value'
        path_format_arguments = {
            'constantParam':
            self._serialize.url("constant_param", constant_param, '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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Product')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized
コード例 #48
0
class AutoRestValidationTest(object):
    """Test Infrastructure for AutoRest. No server backend exists for these tests.

    :param config: Configuration for client.
    :type config: AutoRestValidationTestConfiguration
    """

    def __init__(self, config):

        self._client = ServiceClient(None, config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer()
        self._deserialize = Deserializer(client_models)

        self.config = config

    def validation_of_method_parameters(
            self, resource_group_name, id, custom_headers={}, raw=False, **operation_config):
        """
        Validates input parameters on the method. See swagger for details.

        :param resource_group_name: Required string between 3 and 10 chars
         with pattern [a-zA-Z0-9]+.
        :type resource_group_name: str
        :param id: Required int multiple of 10 from 100 to 1000.
        :type id: int
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: Product or msrest.pipeline.ClientRawResponse
        """
        # Construct URL
        url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
        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'),
            'id': self._serialize.url("id", id, 'int')
        }
        url = url.format(**path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['apiVersion'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

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

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

        deserialized = None

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

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

        return deserialized

    def validation_of_body(
            self, resource_group_name, id, body=None, custom_headers={}, raw=False, **operation_config):
        """
        Validates body parameters on the method. See swagger for details.

        :param resource_group_name: Required string between 3 and 10 chars
         with pattern [a-zA-Z0-9]+.
        :type resource_group_name: str
        :param id: Required int multiple of 10 from 100 to 1000.
        :type id: int
        :param body:
        :type body: Product or None
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: Product or msrest.pipeline.ClientRawResponse
        """
        # Construct URL
        url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
        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'),
            'id': self._serialize.url("id", id, 'int')
        }
        url = url.format(**path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['apiVersion'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if custom_headers:
            header_parameters.update(custom_headers)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Product')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized

    def get_with_constant_in_path(
            self, constant_param, custom_headers={}, raw=False, **operation_config):
        """

        :param constant_param:
        :type constant_param: str
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: None or msrest.pipeline.ClientRawResponse
        """
        # Construct URL
        url = '/validation/constantsInPath/{constantParam}/value'
        path_format_arguments = {
            'constantParam': self._serialize.url("constant_param", constant_param, 'str')
        }
        url = url.format(**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)

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

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

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

    def post_with_constant_in_body(
            self, constant_param, body=None, custom_headers={}, raw=False, **operation_config):
        """

        :param constant_param:
        :type constant_param: str
        :param body:
        :type body: Product or None
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: Product or msrest.pipeline.ClientRawResponse
        """
        # Construct URL
        url = '/validation/constantsInPath/{constantParam}/value'
        path_format_arguments = {
            'constantParam': self._serialize.url("constant_param", constant_param, 'str')
        }
        url = url.format(**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)

        # Construct body
        if body is not None:
            body_content = self._serialize.body(body, 'Product')
        else:
            body_content = None

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

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

        deserialized = None

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

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

        return deserialized
コード例 #49
0
class NetworkManagementClient(object):
    """The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.

    :ivar config: Configuration for client.
    :vartype config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: .operations.ApplicationGatewaysOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: .operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: .operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: .operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: .operations.ExpressRouteServiceProvidersOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: .operations.LoadBalancersOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: .operations.LocalNetworkGatewaysOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: .operations.NetworkInterfacesOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: .operations.NetworkSecurityGroupsOperations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: .operations.PublicIPAddressesOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: .operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: .operations.RoutesOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: .operations.SecurityRulesOperations
    :ivar subnets: Subnets operations
    :vartype subnets: .operations.SubnetsOperations
    :ivar virtual_network_peerings: VirtualNetworkPeerings operations
    :vartype virtual_network_peerings: .operations.VirtualNetworkPeeringsOperations
    :ivar usages: Usages operations
    :vartype usages: .operations.UsagesOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: .operations.VirtualNetworkGatewayConnectionsOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: .operations.VirtualNetworkGatewaysOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: .operations.VirtualNetworksOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: Gets subscription credentials which uniquely
     identify Microsoft Azure subscription. The subscription ID forms part of
     the URI for every service call.
    :type subscription_id: str
    :param api_version: Client Api Version.
    :type api_version: str
    :param accept_language: Gets or sets the preferred language for the
     response.
    :type accept_language: str
    :param long_running_operation_retry_timeout: Gets or sets the retry
     timeout in seconds for Long Running Operations. Default value is 30.
    :type long_running_operation_retry_timeout: int
    :param generate_client_request_id: When set to true a unique
     x-ms-client-request-id value is generated and included in each request.
     Default is true.
    :type generate_client_request_id: bool
    :param str base_url: Service URL
    :param str filepath: Existing config
    """

    def __init__(
            self, credentials, subscription_id, api_version='2016-09-01', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):

        self.config = NetworkManagementClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.routes = RoutesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_peerings = VirtualNetworkPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(
            self, location, domain_name_label=None, custom_headers=None, raw=False, **operation_config):
        """Checks whether a domain name in the cloudapp.net zone is available for
        use.

        :param location: The location of the domain name
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: 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>`.
        :rtype: :class:`DnsNameAvailabilityResult
         <azure.mgmt.network.models.DnsNameAvailabilityResult>`
        :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
         if raw=true
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'
        path_format_arguments = {
            'location': self._serialize.url("location", location, '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 = {}
        if domain_name_label is not None:
            query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
コード例 #50
0
class ResourceGraphClient(SDKClient):
    """Azure Resource Graph API Reference

    :ivar config: Configuration for client.
    :vartype config: ResourceGraphClientConfiguration

    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.resourcegraph.operations.Operations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, base_url=None):

        self.config = ResourceGraphClientConfiguration(credentials, base_url)
        super(ResourceGraphClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2018-09-01-preview'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)

    def resources(
            self, query, custom_headers=None, raw=False, **operation_config):
        """Queries the resources managed by Azure Resource Manager for all
        subscriptions specified in the request.

        :param query: Request specifying query and its options.
        :type query: ~azure.mgmt.resourcegraph.models.QueryRequest
        :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: QueryResponse or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.resourcegraph.models.QueryResponse or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.resourcegraph.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.resources.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(query, 'QueryRequest')

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

        deserialized = None

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

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

        return deserialized
    resources.metadata = {'url': '/providers/Microsoft.ResourceGraph/resources'}
コード例 #51
0
class AzureReservationAPI(SDKClient):
    """This API describe Azure Reservation

    :ivar config: Configuration for client.
    :vartype config: AzureReservationAPIConfiguration

    :ivar reservation_order: ReservationOrder operations
    :vartype reservation_order: azure.mgmt.reservations.operations.ReservationOrderOperations
    :ivar reservation: Reservation operations
    :vartype reservation: azure.mgmt.reservations.operations.ReservationOperations
    :ivar operation: Operation operations
    :vartype operation: azure.mgmt.reservations.operations.OperationOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param str base_url: Service URL
    """
    def __init__(self, credentials, base_url=None):

        self.config = AzureReservationAPIConfiguration(credentials, base_url)
        super(AzureReservationAPI, self).__init__(self.config.credentials,
                                                  self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self.api_version = '2018-06-01'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.reservation_order = ReservationOrderOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.reservation = ReservationOperations(self._client, self.config,
                                                 self._serialize,
                                                 self._deserialize)
        self.operation = OperationOperations(self._client, self.config,
                                             self._serialize,
                                             self._deserialize)

    def get_catalog(self,
                    subscription_id,
                    reserved_resource_type,
                    location=None,
                    custom_headers=None,
                    raw=False,
                    **operation_config):
        """Get the regions and skus that are available for RI purchase for the
        specified Azure subscription.

        :param subscription_id: Id of the subscription
        :type subscription_id: str
        :param reserved_resource_type: The type of the resource for which the
         skus should be provided.
        :type reserved_resource_type: str
        :param location: Filters the skus based on the location specified in
         this parameter. This can be an azure region or global
        :type location: 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[~azure.mgmt.reservations.models.Catalog] or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorException<azure.mgmt.reservations.models.ErrorException>`
        """
        # Construct URL
        url = self.get_catalog.metadata['url']
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("subscription_id", subscription_id, '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')
        query_parameters['reservedResourceType'] = self._serialize.query(
            "reserved_resource_type", reserved_resource_type, 'str')
        if location is not None:
            query_parameters['location'] = self._serialize.query(
                "location", location, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

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

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('[Catalog]', response)

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

        return deserialized

    get_catalog.metadata = {
        'url':
        '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs'
    }

    def get_applied_reservation_list(self,
                                     subscription_id,
                                     custom_headers=None,
                                     raw=False,
                                     **operation_config):
        """Get list of applicable `Reservation`s.

        Get applicable `Reservation`s that are applied to this subscription.

        :param subscription_id: Id of the subscription
        :type subscription_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: AppliedReservations or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.reservations.models.AppliedReservations or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorException<azure.mgmt.reservations.models.ErrorException>`
        """
        # Construct URL
        url = self.get_applied_reservation_list.metadata['url']
        path_format_arguments = {
            'subscriptionId':
            self._serialize.url("subscription_id", subscription_id, '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['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

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

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

        deserialized = None

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

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

        return deserialized

    get_applied_reservation_list.metadata = {
        'url':
        '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations'
    }
コード例 #52
0
class NetworkManagementClient(object):
    """The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resrources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service.

    :param config: Configuration for client.
    :type config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: .operations.ApplicationGatewaysOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: .operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: .operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: .operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: .operations.ExpressRouteServiceProvidersOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: .operations.LoadBalancersOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: .operations.LocalNetworkGatewaysOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: .operations.NetworkInterfacesOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: .operations.NetworkSecurityGroupsOperations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: .operations.PublicIPAddressesOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: .operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: .operations.RoutesOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: .operations.SecurityRulesOperations
    :ivar subnets: Subnets operations
    :vartype subnets: .operations.SubnetsOperations
    :ivar usages: Usages operations
    :vartype usages: .operations.UsagesOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: .operations.VirtualNetworkGatewayConnectionsOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: .operations.VirtualNetworkGatewaysOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: .operations.VirtualNetworksOperations
    """

    def __init__(self, config):

        self._client = ServiceClient(config.credentials, config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer()
        self._deserialize = Deserializer(client_models)

        self.config = config
        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.routes = RoutesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(
            self, location, domain_name_label=None, custom_headers={}, raw=False, **operation_config):
        """
        Checks whether a domain name in the cloudapp.net zone is available for
        use.

        :param location: The location of the domain name
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: str
        :param dict custom_headers: headers that will be added to the request
        :param boolean raw: returns the direct response alongside the
         deserialized response
        :rtype: DnsNameAvailabilityResult
        :rtype: msrest.pipeline.ClientRawResponse if raw=True
        """
        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'
        path_format_arguments = {
            'location': self._serialize.url("location", location, '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 = {}
        if domain_name_label is not None:
            query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.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, **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
コード例 #53
0
class LocationClient(VssClient):
    """Location
    :param str base_url: Service URL
    :param Authentication creds: Authenticated credentials.
    """

    def __init__(self, base_url=None, creds=None):
        super(LocationClient, self).__init__(base_url, creds)
        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

    resource_area_identifier = None

    def get_connection_data(self, connect_options=None, last_change_id=None, last_change_id64=None):
        """GetConnectionData.
        [Preview API] This was copied and adapted from TeamFoundationConnectionService.Connect()
        :param str connect_options:
        :param int last_change_id: Obsolete 32-bit LastChangeId
        :param long last_change_id64: Non-truncated 64-bit LastChangeId
        :rtype: :class:`<ConnectionData> <location.v4_0.models.ConnectionData>`
        """
        query_parameters = {}
        if connect_options is not None:
            query_parameters['connectOptions'] = self._serialize.query('connect_options', connect_options, 'str')
        if last_change_id is not None:
            query_parameters['lastChangeId'] = self._serialize.query('last_change_id', last_change_id, 'int')
        if last_change_id64 is not None:
            query_parameters['lastChangeId64'] = self._serialize.query('last_change_id64', last_change_id64, 'long')
        response = self._send(http_method='GET',
                              location_id='00d9565f-ed9c-4a06-9a50-00e7896ccab4',
                              version='4.0-preview.1',
                              query_parameters=query_parameters)
        return self._deserialize('ConnectionData', response)

    def get_resource_area(self, area_id):
        """GetResourceArea.
        [Preview API]
        :param str area_id:
        :rtype: :class:`<ResourceAreaInfo> <location.v4_0.models.ResourceAreaInfo>`
        """
        route_values = {}
        if area_id is not None:
            route_values['areaId'] = self._serialize.url('area_id', area_id, 'str')
        response = self._send(http_method='GET',
                              location_id='e81700f7-3be2-46de-8624-2eb35882fcaa',
                              version='4.0-preview.1',
                              route_values=route_values)
        return self._deserialize('ResourceAreaInfo', response)

    def get_resource_areas(self):
        """GetResourceAreas.
        [Preview API]
        :rtype: [ResourceAreaInfo]
        """
        response = self._send(http_method='GET',
                              location_id='e81700f7-3be2-46de-8624-2eb35882fcaa',
                              version='4.0-preview.1')
        return self._deserialize('[ResourceAreaInfo]', self._unwrap_collection(response))

    def delete_service_definition(self, service_type, identifier):
        """DeleteServiceDefinition.
        [Preview API]
        :param str service_type:
        :param str identifier:
        """
        route_values = {}
        if service_type is not None:
            route_values['serviceType'] = self._serialize.url('service_type', service_type, 'str')
        if identifier is not None:
            route_values['identifier'] = self._serialize.url('identifier', identifier, 'str')
        self._send(http_method='DELETE',
                   location_id='d810a47d-f4f4-4a62-a03f-fa1860585c4c',
                   version='4.0-preview.1',
                   route_values=route_values)

    def get_service_definition(self, service_type, identifier, allow_fault_in=None):
        """GetServiceDefinition.
        [Preview API]
        :param str service_type:
        :param str identifier:
        :param bool allow_fault_in:
        :rtype: :class:`<ServiceDefinition> <location.v4_0.models.ServiceDefinition>`
        """
        route_values = {}
        if service_type is not None:
            route_values['serviceType'] = self._serialize.url('service_type', service_type, 'str')
        if identifier is not None:
            route_values['identifier'] = self._serialize.url('identifier', identifier, 'str')
        query_parameters = {}
        if allow_fault_in is not None:
            query_parameters['allowFaultIn'] = self._serialize.query('allow_fault_in', allow_fault_in, 'bool')
        response = self._send(http_method='GET',
                              location_id='d810a47d-f4f4-4a62-a03f-fa1860585c4c',
                              version='4.0-preview.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('ServiceDefinition', response)

    def get_service_definitions(self, service_type=None):
        """GetServiceDefinitions.
        [Preview API]
        :param str service_type:
        :rtype: [ServiceDefinition]
        """
        route_values = {}
        if service_type is not None:
            route_values['serviceType'] = self._serialize.url('service_type', service_type, 'str')
        response = self._send(http_method='GET',
                              location_id='d810a47d-f4f4-4a62-a03f-fa1860585c4c',
                              version='4.0-preview.1',
                              route_values=route_values)
        return self._deserialize('[ServiceDefinition]', self._unwrap_collection(response))

    def update_service_definitions(self, service_definitions):
        """UpdateServiceDefinitions.
        [Preview API]
        :param :class:`<VssJsonCollectionWrapper> <location.v4_0.models.VssJsonCollectionWrapper>` service_definitions:
        """
        content = self._serialize.body(service_definitions, 'VssJsonCollectionWrapper')
        self._send(http_method='PATCH',
                   location_id='d810a47d-f4f4-4a62-a03f-fa1860585c4c',
                   version='4.0-preview.1',
                   content=content)
コード例 #54
0
class NetworkManagementClient(object):
    """Network Client

    :ivar config: Configuration for client.
    :vartype config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: azure.mgmt.network.v2017_09_01.operations.ApplicationGatewaysOperations
    :ivar application_security_groups: ApplicationSecurityGroups operations
    :vartype application_security_groups: azure.mgmt.network.v2017_09_01.operations.ApplicationSecurityGroupsOperations
    :ivar available_endpoint_services: AvailableEndpointServices operations
    :vartype available_endpoint_services: azure.mgmt.network.v2017_09_01.operations.AvailableEndpointServicesOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: azure.mgmt.network.v2017_09_01.operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: azure.mgmt.network.v2017_09_01.operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: azure.mgmt.network.v2017_09_01.operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: azure.mgmt.network.v2017_09_01.operations.ExpressRouteServiceProvidersOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: azure.mgmt.network.v2017_09_01.operations.LoadBalancersOperations
    :ivar load_balancer_backend_address_pools: LoadBalancerBackendAddressPools operations
    :vartype load_balancer_backend_address_pools: azure.mgmt.network.v2017_09_01.operations.LoadBalancerBackendAddressPoolsOperations
    :ivar load_balancer_frontend_ip_configurations: LoadBalancerFrontendIPConfigurations operations
    :vartype load_balancer_frontend_ip_configurations: azure.mgmt.network.v2017_09_01.operations.LoadBalancerFrontendIPConfigurationsOperations
    :ivar inbound_nat_rules: InboundNatRules operations
    :vartype inbound_nat_rules: azure.mgmt.network.v2017_09_01.operations.InboundNatRulesOperations
    :ivar load_balancer_load_balancing_rules: LoadBalancerLoadBalancingRules operations
    :vartype load_balancer_load_balancing_rules: azure.mgmt.network.v2017_09_01.operations.LoadBalancerLoadBalancingRulesOperations
    :ivar load_balancer_network_interfaces: LoadBalancerNetworkInterfaces operations
    :vartype load_balancer_network_interfaces: azure.mgmt.network.v2017_09_01.operations.LoadBalancerNetworkInterfacesOperations
    :ivar load_balancer_probes: LoadBalancerProbes operations
    :vartype load_balancer_probes: azure.mgmt.network.v2017_09_01.operations.LoadBalancerProbesOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: azure.mgmt.network.v2017_09_01.operations.NetworkInterfacesOperations
    :ivar network_interface_ip_configurations: NetworkInterfaceIPConfigurations operations
    :vartype network_interface_ip_configurations: azure.mgmt.network.v2017_09_01.operations.NetworkInterfaceIPConfigurationsOperations
    :ivar network_interface_load_balancers: NetworkInterfaceLoadBalancers operations
    :vartype network_interface_load_balancers: azure.mgmt.network.v2017_09_01.operations.NetworkInterfaceLoadBalancersOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: azure.mgmt.network.v2017_09_01.operations.NetworkSecurityGroupsOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: azure.mgmt.network.v2017_09_01.operations.SecurityRulesOperations
    :ivar default_security_rules: DefaultSecurityRules operations
    :vartype default_security_rules: azure.mgmt.network.v2017_09_01.operations.DefaultSecurityRulesOperations
    :ivar network_watchers: NetworkWatchers operations
    :vartype network_watchers: azure.mgmt.network.v2017_09_01.operations.NetworkWatchersOperations
    :ivar packet_captures: PacketCaptures operations
    :vartype packet_captures: azure.mgmt.network.v2017_09_01.operations.PacketCapturesOperations
    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.network.v2017_09_01.operations.Operations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: azure.mgmt.network.v2017_09_01.operations.PublicIPAddressesOperations
    :ivar route_filters: RouteFilters operations
    :vartype route_filters: azure.mgmt.network.v2017_09_01.operations.RouteFiltersOperations
    :ivar route_filter_rules: RouteFilterRules operations
    :vartype route_filter_rules: azure.mgmt.network.v2017_09_01.operations.RouteFilterRulesOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: azure.mgmt.network.v2017_09_01.operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: azure.mgmt.network.v2017_09_01.operations.RoutesOperations
    :ivar bgp_service_communities: BgpServiceCommunities operations
    :vartype bgp_service_communities: azure.mgmt.network.v2017_09_01.operations.BgpServiceCommunitiesOperations
    :ivar usages: Usages operations
    :vartype usages: azure.mgmt.network.v2017_09_01.operations.UsagesOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: azure.mgmt.network.v2017_09_01.operations.VirtualNetworksOperations
    :ivar subnets: Subnets operations
    :vartype subnets: azure.mgmt.network.v2017_09_01.operations.SubnetsOperations
    :ivar virtual_network_peerings: VirtualNetworkPeerings operations
    :vartype virtual_network_peerings: azure.mgmt.network.v2017_09_01.operations.VirtualNetworkPeeringsOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: azure.mgmt.network.v2017_09_01.operations.VirtualNetworkGatewaysOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: azure.mgmt.network.v2017_09_01.operations.VirtualNetworkGatewayConnectionsOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: azure.mgmt.network.v2017_09_01.operations.LocalNetworkGatewaysOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription credentials which uniquely
     identify the Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, subscription_id, base_url=None):

        self.config = NetworkManagementClientConfiguration(credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.application_security_groups = ApplicationSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_endpoint_services = AvailableEndpointServicesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_backend_address_pools = LoadBalancerBackendAddressPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_frontend_ip_configurations = LoadBalancerFrontendIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.inbound_nat_rules = InboundNatRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_load_balancing_rules = LoadBalancerLoadBalancingRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_network_interfaces = LoadBalancerNetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_probes = LoadBalancerProbesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_ip_configurations = NetworkInterfaceIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_load_balancers = NetworkInterfaceLoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.default_security_rules = DefaultSecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_watchers = NetworkWatchersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.packet_captures = PacketCapturesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_filters = RouteFiltersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_filter_rules = RouteFilterRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.routes = RoutesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.bgp_service_communities = BgpServiceCommunitiesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_peerings = VirtualNetworkPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(
            self, location, domain_name_label, custom_headers=None, raw=False, **operation_config):
        """Checks whether a domain name in the cloudapp.azure.com zone is
        available for use.

        :param location: The location of the domain name.
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: 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: DnsNameAvailabilityResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.network.v2017_09_01.models.DnsNameAvailabilityResult or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2017-09-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'
        path_format_arguments = {
            'location': self._serialize.url("location", location, '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 = {}
        query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query("api_version", 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]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
コード例 #55
0
class NetworkManagementClient(SDKClient):
    """Network Client

    :ivar config: Configuration for client.
    :vartype config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: azure.mgmt.network.v2018_12_01.operations.ApplicationGatewaysOperations
    :ivar application_security_groups: ApplicationSecurityGroups operations
    :vartype application_security_groups: azure.mgmt.network.v2018_12_01.operations.ApplicationSecurityGroupsOperations
    :ivar available_delegations: AvailableDelegations operations
    :vartype available_delegations: azure.mgmt.network.v2018_12_01.operations.AvailableDelegationsOperations
    :ivar available_resource_group_delegations: AvailableResourceGroupDelegations operations
    :vartype available_resource_group_delegations: azure.mgmt.network.v2018_12_01.operations.AvailableResourceGroupDelegationsOperations
    :ivar azure_firewalls: AzureFirewalls operations
    :vartype azure_firewalls: azure.mgmt.network.v2018_12_01.operations.AzureFirewallsOperations
    :ivar azure_firewall_fqdn_tags: AzureFirewallFqdnTags operations
    :vartype azure_firewall_fqdn_tags: azure.mgmt.network.v2018_12_01.operations.AzureFirewallFqdnTagsOperations
    :ivar ddos_custom_policies: DdosCustomPolicies operations
    :vartype ddos_custom_policies: azure.mgmt.network.v2018_12_01.operations.DdosCustomPoliciesOperations
    :ivar ddos_protection_plans: DdosProtectionPlans operations
    :vartype ddos_protection_plans: azure.mgmt.network.v2018_12_01.operations.DdosProtectionPlansOperations
    :ivar available_endpoint_services: AvailableEndpointServices operations
    :vartype available_endpoint_services: azure.mgmt.network.v2018_12_01.operations.AvailableEndpointServicesOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: azure.mgmt.network.v2018_12_01.operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: azure.mgmt.network.v2018_12_01.operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuit_connections: ExpressRouteCircuitConnections operations
    :vartype express_route_circuit_connections: azure.mgmt.network.v2018_12_01.operations.ExpressRouteCircuitConnectionsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: azure.mgmt.network.v2018_12_01.operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: azure.mgmt.network.v2018_12_01.operations.ExpressRouteServiceProvidersOperations
    :ivar express_route_cross_connections: ExpressRouteCrossConnections operations
    :vartype express_route_cross_connections: azure.mgmt.network.v2018_12_01.operations.ExpressRouteCrossConnectionsOperations
    :ivar express_route_cross_connection_peerings: ExpressRouteCrossConnectionPeerings operations
    :vartype express_route_cross_connection_peerings: azure.mgmt.network.v2018_12_01.operations.ExpressRouteCrossConnectionPeeringsOperations
    :ivar express_route_gateways: ExpressRouteGateways operations
    :vartype express_route_gateways: azure.mgmt.network.v2018_12_01.operations.ExpressRouteGatewaysOperations
    :ivar express_route_connections: ExpressRouteConnections operations
    :vartype express_route_connections: azure.mgmt.network.v2018_12_01.operations.ExpressRouteConnectionsOperations
    :ivar express_route_ports_locations: ExpressRoutePortsLocations operations
    :vartype express_route_ports_locations: azure.mgmt.network.v2018_12_01.operations.ExpressRoutePortsLocationsOperations
    :ivar express_route_ports: ExpressRoutePorts operations
    :vartype express_route_ports: azure.mgmt.network.v2018_12_01.operations.ExpressRoutePortsOperations
    :ivar express_route_links: ExpressRouteLinks operations
    :vartype express_route_links: azure.mgmt.network.v2018_12_01.operations.ExpressRouteLinksOperations
    :ivar interface_endpoints: InterfaceEndpoints operations
    :vartype interface_endpoints: azure.mgmt.network.v2018_12_01.operations.InterfaceEndpointsOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: azure.mgmt.network.v2018_12_01.operations.LoadBalancersOperations
    :ivar load_balancer_backend_address_pools: LoadBalancerBackendAddressPools operations
    :vartype load_balancer_backend_address_pools: azure.mgmt.network.v2018_12_01.operations.LoadBalancerBackendAddressPoolsOperations
    :ivar load_balancer_frontend_ip_configurations: LoadBalancerFrontendIPConfigurations operations
    :vartype load_balancer_frontend_ip_configurations: azure.mgmt.network.v2018_12_01.operations.LoadBalancerFrontendIPConfigurationsOperations
    :ivar inbound_nat_rules: InboundNatRules operations
    :vartype inbound_nat_rules: azure.mgmt.network.v2018_12_01.operations.InboundNatRulesOperations
    :ivar load_balancer_load_balancing_rules: LoadBalancerLoadBalancingRules operations
    :vartype load_balancer_load_balancing_rules: azure.mgmt.network.v2018_12_01.operations.LoadBalancerLoadBalancingRulesOperations
    :ivar load_balancer_outbound_rules: LoadBalancerOutboundRules operations
    :vartype load_balancer_outbound_rules: azure.mgmt.network.v2018_12_01.operations.LoadBalancerOutboundRulesOperations
    :ivar load_balancer_network_interfaces: LoadBalancerNetworkInterfaces operations
    :vartype load_balancer_network_interfaces: azure.mgmt.network.v2018_12_01.operations.LoadBalancerNetworkInterfacesOperations
    :ivar load_balancer_probes: LoadBalancerProbes operations
    :vartype load_balancer_probes: azure.mgmt.network.v2018_12_01.operations.LoadBalancerProbesOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: azure.mgmt.network.v2018_12_01.operations.NetworkInterfacesOperations
    :ivar network_interface_ip_configurations: NetworkInterfaceIPConfigurations operations
    :vartype network_interface_ip_configurations: azure.mgmt.network.v2018_12_01.operations.NetworkInterfaceIPConfigurationsOperations
    :ivar network_interface_load_balancers: NetworkInterfaceLoadBalancers operations
    :vartype network_interface_load_balancers: azure.mgmt.network.v2018_12_01.operations.NetworkInterfaceLoadBalancersOperations
    :ivar network_interface_tap_configurations: NetworkInterfaceTapConfigurations operations
    :vartype network_interface_tap_configurations: azure.mgmt.network.v2018_12_01.operations.NetworkInterfaceTapConfigurationsOperations
    :ivar network_profiles: NetworkProfiles operations
    :vartype network_profiles: azure.mgmt.network.v2018_12_01.operations.NetworkProfilesOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: azure.mgmt.network.v2018_12_01.operations.NetworkSecurityGroupsOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: azure.mgmt.network.v2018_12_01.operations.SecurityRulesOperations
    :ivar default_security_rules: DefaultSecurityRules operations
    :vartype default_security_rules: azure.mgmt.network.v2018_12_01.operations.DefaultSecurityRulesOperations
    :ivar network_watchers: NetworkWatchers operations
    :vartype network_watchers: azure.mgmt.network.v2018_12_01.operations.NetworkWatchersOperations
    :ivar packet_captures: PacketCaptures operations
    :vartype packet_captures: azure.mgmt.network.v2018_12_01.operations.PacketCapturesOperations
    :ivar connection_monitors: ConnectionMonitors operations
    :vartype connection_monitors: azure.mgmt.network.v2018_12_01.operations.ConnectionMonitorsOperations
    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.network.v2018_12_01.operations.Operations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: azure.mgmt.network.v2018_12_01.operations.PublicIPAddressesOperations
    :ivar public_ip_prefixes: PublicIPPrefixes operations
    :vartype public_ip_prefixes: azure.mgmt.network.v2018_12_01.operations.PublicIPPrefixesOperations
    :ivar route_filters: RouteFilters operations
    :vartype route_filters: azure.mgmt.network.v2018_12_01.operations.RouteFiltersOperations
    :ivar route_filter_rules: RouteFilterRules operations
    :vartype route_filter_rules: azure.mgmt.network.v2018_12_01.operations.RouteFilterRulesOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: azure.mgmt.network.v2018_12_01.operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: azure.mgmt.network.v2018_12_01.operations.RoutesOperations
    :ivar bgp_service_communities: BgpServiceCommunities operations
    :vartype bgp_service_communities: azure.mgmt.network.v2018_12_01.operations.BgpServiceCommunitiesOperations
    :ivar service_endpoint_policies: ServiceEndpointPolicies operations
    :vartype service_endpoint_policies: azure.mgmt.network.v2018_12_01.operations.ServiceEndpointPoliciesOperations
    :ivar service_endpoint_policy_definitions: ServiceEndpointPolicyDefinitions operations
    :vartype service_endpoint_policy_definitions: azure.mgmt.network.v2018_12_01.operations.ServiceEndpointPolicyDefinitionsOperations
    :ivar usages: Usages operations
    :vartype usages: azure.mgmt.network.v2018_12_01.operations.UsagesOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: azure.mgmt.network.v2018_12_01.operations.VirtualNetworksOperations
    :ivar subnets: Subnets operations
    :vartype subnets: azure.mgmt.network.v2018_12_01.operations.SubnetsOperations
    :ivar virtual_network_peerings: VirtualNetworkPeerings operations
    :vartype virtual_network_peerings: azure.mgmt.network.v2018_12_01.operations.VirtualNetworkPeeringsOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: azure.mgmt.network.v2018_12_01.operations.VirtualNetworkGatewaysOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: azure.mgmt.network.v2018_12_01.operations.VirtualNetworkGatewayConnectionsOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: azure.mgmt.network.v2018_12_01.operations.LocalNetworkGatewaysOperations
    :ivar virtual_network_taps: VirtualNetworkTaps operations
    :vartype virtual_network_taps: azure.mgmt.network.v2018_12_01.operations.VirtualNetworkTapsOperations
    :ivar virtual_wans: VirtualWans operations
    :vartype virtual_wans: azure.mgmt.network.v2018_12_01.operations.VirtualWansOperations
    :ivar vpn_sites: VpnSites operations
    :vartype vpn_sites: azure.mgmt.network.v2018_12_01.operations.VpnSitesOperations
    :ivar vpn_sites_configuration: VpnSitesConfiguration operations
    :vartype vpn_sites_configuration: azure.mgmt.network.v2018_12_01.operations.VpnSitesConfigurationOperations
    :ivar virtual_hubs: VirtualHubs operations
    :vartype virtual_hubs: azure.mgmt.network.v2018_12_01.operations.VirtualHubsOperations
    :ivar hub_virtual_network_connections: HubVirtualNetworkConnections operations
    :vartype hub_virtual_network_connections: azure.mgmt.network.v2018_12_01.operations.HubVirtualNetworkConnectionsOperations
    :ivar vpn_gateways: VpnGateways operations
    :vartype vpn_gateways: azure.mgmt.network.v2018_12_01.operations.VpnGatewaysOperations
    :ivar vpn_connections: VpnConnections operations
    :vartype vpn_connections: azure.mgmt.network.v2018_12_01.operations.VpnConnectionsOperations
    :ivar p2s_vpn_server_configurations: P2sVpnServerConfigurations operations
    :vartype p2s_vpn_server_configurations: azure.mgmt.network.v2018_12_01.operations.P2sVpnServerConfigurationsOperations
    :ivar p2s_vpn_gateways: P2sVpnGateways operations
    :vartype p2s_vpn_gateways: azure.mgmt.network.v2018_12_01.operations.P2sVpnGatewaysOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription credentials which uniquely
     identify the Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """
    def __init__(self, credentials, subscription_id, base_url=None):

        self.config = NetworkManagementClientConfiguration(
            credentials, subscription_id, base_url)
        super(NetworkManagementClient, self).__init__(self.config.credentials,
                                                      self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.application_security_groups = ApplicationSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_delegations = AvailableDelegationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_resource_group_delegations = AvailableResourceGroupDelegationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.azure_firewalls = AzureFirewallsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.azure_firewall_fqdn_tags = AzureFirewallFqdnTagsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.ddos_custom_policies = DdosCustomPoliciesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.ddos_protection_plans = DdosProtectionPlansOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_endpoint_services = AvailableEndpointServicesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_connections = ExpressRouteCircuitConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_cross_connections = ExpressRouteCrossConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_cross_connection_peerings = ExpressRouteCrossConnectionPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_gateways = ExpressRouteGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_connections = ExpressRouteConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_ports_locations = ExpressRoutePortsLocationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_ports = ExpressRoutePortsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_links = ExpressRouteLinksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.interface_endpoints = InterfaceEndpointsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(self._client,
                                                      self.config,
                                                      self._serialize,
                                                      self._deserialize)
        self.load_balancer_backend_address_pools = LoadBalancerBackendAddressPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_frontend_ip_configurations = LoadBalancerFrontendIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.inbound_nat_rules = InboundNatRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_load_balancing_rules = LoadBalancerLoadBalancingRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_outbound_rules = LoadBalancerOutboundRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_network_interfaces = LoadBalancerNetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_probes = LoadBalancerProbesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_ip_configurations = NetworkInterfaceIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_load_balancers = NetworkInterfaceLoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_tap_configurations = NetworkInterfaceTapConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_profiles = NetworkProfilesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(self._client,
                                                      self.config,
                                                      self._serialize,
                                                      self._deserialize)
        self.default_security_rules = DefaultSecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_watchers = NetworkWatchersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.packet_captures = PacketCapturesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.connection_monitors = ConnectionMonitorsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.operations = Operations(self._client, self.config,
                                     self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_prefixes = PublicIPPrefixesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_filters = RouteFiltersOperations(self._client, self.config,
                                                    self._serialize,
                                                    self._deserialize)
        self.route_filter_rules = RouteFilterRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(self._client, self.config,
                                                  self._serialize,
                                                  self._deserialize)
        self.routes = RoutesOperations(self._client, self.config,
                                       self._serialize, self._deserialize)
        self.bgp_service_communities = BgpServiceCommunitiesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.service_endpoint_policies = ServiceEndpointPoliciesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.service_endpoint_policy_definitions = ServiceEndpointPolicyDefinitionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(self._client, self.config,
                                       self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(self._client, self.config,
                                         self._serialize, self._deserialize)
        self.virtual_network_peerings = VirtualNetworkPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_taps = VirtualNetworkTapsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_wans = VirtualWansOperations(self._client, self.config,
                                                  self._serialize,
                                                  self._deserialize)
        self.vpn_sites = VpnSitesOperations(self._client, self.config,
                                            self._serialize, self._deserialize)
        self.vpn_sites_configuration = VpnSitesConfigurationOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_hubs = VirtualHubsOperations(self._client, self.config,
                                                  self._serialize,
                                                  self._deserialize)
        self.hub_virtual_network_connections = HubVirtualNetworkConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.vpn_gateways = VpnGatewaysOperations(self._client, self.config,
                                                  self._serialize,
                                                  self._deserialize)
        self.vpn_connections = VpnConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.p2s_vpn_server_configurations = P2sVpnServerConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.p2s_vpn_gateways = P2sVpnGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(self,
                                    location,
                                    domain_name_label,
                                    custom_headers=None,
                                    raw=False,
                                    **operation_config):
        """Checks whether a domain name in the cloudapp.azure.com zone is
        available for use.

        :param location: The location of the domain name.
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: 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: DnsNameAvailabilityResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.network.v2018_12_01.models.DnsNameAvailabilityResult or
         ~msrest.pipeline.ClientRawResponse
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2018-12-01"

        # Construct URL
        url = self.check_dns_name_availability.metadata['url']
        path_format_arguments = {
            'location':
            self._serialize.url("location", location, '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 = {}
        query_parameters['domainNameLabel'] = self._serialize.query(
            "domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query(
            "api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

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

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized

    check_dns_name_availability.metadata = {
        'url':
        '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'
    }

    def supported_security_providers(self,
                                     resource_group_name,
                                     virtual_wan_name,
                                     custom_headers=None,
                                     raw=False,
                                     **operation_config):
        """Gives the supported security providers for the virtual wan.

        :param resource_group_name: The resource group name.
        :type resource_group_name: str
        :param virtual_wan_name: The name of the VirtualWAN for which
         supported security providers are needed.
        :type virtual_wan_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: VirtualWanSecurityProviders or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.network.v2018_12_01.models.VirtualWanSecurityProviders or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorException<azure.mgmt.network.v2018_12_01.models.ErrorException>`
        """
        api_version = "2018-12-01"

        # Construct URL
        url = self.supported_security_providers.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'),
            'virtualWANName':
            self._serialize.url("virtual_wan_name", virtual_wan_name, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query(
            "api_version", api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header(
                "self.config.accept_language", self.config.accept_language,
                'str')

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

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

        deserialized = None

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

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

        return deserialized

    supported_security_providers.metadata = {
        'url':
        '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/supportedSecurityProviders'
    }
コード例 #56
0
class SpellCheckAPI(object):
    """The Spell Check API - V7 lets you check a text string for spelling and grammar errors.

    :ivar config: Configuration for client.
    :vartype config: SpellCheckAPIConfiguration

    :param credentials: Subscription credentials which uniquely identify
     client subscription.
    :type credentials: None
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, base_url=None):

        self.config = SpellCheckAPIConfiguration(credentials, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '1.0'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def spell_checker(
            self, text, accept_language=None, pragma=None, user_agent=None, client_id=None, client_ip=None, location=None, action_type=None, app_name=None, country_code=None, client_machine_name=None, doc_id=None, market=None, session_id=None, set_lang=None, user_id=None, mode=None, pre_context_text=None, post_context_text=None, custom_headers=None, raw=False, **operation_config):
        """The Bing Spell Check API lets you perform contextual grammar and spell
        checking. Bing has developed a web-based spell-checker that leverages
        machine learning and statistical machine translation to dynamically
        train a constantly evolving and highly contextual algorithm. The
        spell-checker is based on a massive corpus of web searches and
        documents.

        :param text: The text string to check for spelling and grammar errors.
         The combined length of the text string, preContextText string, and
         postContextText string may not exceed 10,000 characters. You may
         specify this parameter in the query string of a GET request or in the
         body of a POST request. Because of the query string length limit,
         you'll typically use a POST request unless you're checking only short
         strings.
        :type text: str
        :param accept_language: A comma-delimited list of one or more
         languages to use for user interface strings. The list is in decreasing
         order of preference. For additional information, including expected
         format, see
         [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
         This header and the setLang query parameter are mutually exclusive; do
         not specify both. If you set this header, you must also specify the cc
         query parameter. Bing will use the first supported language it finds
         from the list, and combine that language with the cc parameter value
         to determine the market to return results for. If the list does not
         include a supported language, Bing will find the closest language and
         market that supports the request, and may use an aggregated or default
         market for the results instead of a specified one. You should use this
         header and the cc query parameter only if you specify multiple
         languages; otherwise, you should use the mkt and setLang query
         parameters. A user interface string is a string that's used as a label
         in a user interface. There are very few user interface strings in the
         JSON response objects. Any links in the response objects to Bing.com
         properties will apply the specified language.
        :type accept_language: str
        :param pragma: By default, Bing returns cached content, if available.
         To prevent Bing from returning cached content, set the Pragma header
         to no-cache (for example, Pragma: no-cache).
        :type pragma: str
        :param user_agent: The user agent originating the request. Bing uses
         the user agent to provide mobile users with an optimized experience.
         Although optional, you are strongly encouraged to always specify this
         header. The user-agent should be the same string that any commonly
         used browser would send. For information about user agents, see [RFC
         2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
        :type user_agent: str
        :param client_id: Bing uses this header to provide users with
         consistent behavior across Bing API calls. Bing often flights new
         features and improvements, and it uses the client ID as a key for
         assigning traffic on different flights. If you do not use the same
         client ID for a user across multiple requests, then Bing may assign
         the user to multiple conflicting flights. Being assigned to multiple
         conflicting flights can lead to an inconsistent user experience. For
         example, if the second request has a different flight assignment than
         the first, the experience may be unexpected. Also, Bing can use the
         client ID to tailor web results to that client ID’s search history,
         providing a richer experience for the user. Bing also uses this header
         to help improve result rankings by analyzing the activity generated by
         a client ID. The relevance improvements help with better quality of
         results delivered by Bing APIs and in turn enables higher
         click-through rates for the API consumer. IMPORTANT: Although
         optional, you should consider this header required. Persisting the
         client ID across multiple requests for the same end user and device
         combination enables 1) the API consumer to receive a consistent user
         experience, and 2) higher click-through rates via better quality of
         results from the Bing APIs. Each user that uses your application on
         the device must have a unique, Bing generated client ID. If you do not
         include this header in the request, Bing generates an ID and returns
         it in the X-MSEdge-ClientID response header. The only time that you
         should NOT include this header in a request is the first time the user
         uses your app on that device. Use the client ID for each Bing API
         request that your app makes for this user on the device. Persist the
         client ID. To persist the ID in a browser app, use a persistent HTTP
         cookie to ensure the ID is used across all sessions. Do not use a
         session cookie. For other apps such as mobile apps, use the device's
         persistent storage to persist the ID. The next time the user uses your
         app on that device, get the client ID that you persisted. Bing
         responses may or may not include this header. If the response includes
         this header, capture the client ID and use it for all subsequent Bing
         requests for the user on that device. If you include the
         X-MSEdge-ClientID, you must not include cookies in the request.
        :type client_id: str
        :param client_ip: The IPv4 or IPv6 address of the client device. The
         IP address is used to discover the user's location. Bing uses the
         location information to determine safe search behavior. Although
         optional, you are encouraged to always specify this header and the
         X-Search-Location header. Do not obfuscate the address (for example,
         by changing the last octet to 0). Obfuscating the address results in
         the location not being anywhere near the device's actual location,
         which may result in Bing serving erroneous results.
        :type client_ip: str
        :param location: A semicolon-delimited list of key/value pairs that
         describe the client's geographical location. Bing uses the location
         information to determine safe search behavior and to return relevant
         local content. Specify the key/value pair as <key>:<value>. The
         following are the keys that you use to specify the user's location.
         lat (required): The latitude of the client's location, in degrees. The
         latitude must be greater than or equal to -90.0 and less than or equal
         to +90.0. Negative values indicate southern latitudes and positive
         values indicate northern latitudes. long (required): The longitude of
         the client's location, in degrees. The longitude must be greater than
         or equal to -180.0 and less than or equal to +180.0. Negative values
         indicate western longitudes and positive values indicate eastern
         longitudes. re (required): The radius, in meters, which specifies the
         horizontal accuracy of the coordinates. Pass the value returned by the
         device's location service. Typical values might be 22m for GPS/Wi-Fi,
         380m for cell tower triangulation, and 18,000m for reverse IP lookup.
         ts (optional): The UTC UNIX timestamp of when the client was at the
         location. (The UNIX timestamp is the number of seconds since January
         1, 1970.) head (optional): The client's relative heading or direction
         of travel. Specify the direction of travel as degrees from 0 through
         360, counting clockwise relative to true north. Specify this key only
         if the sp key is nonzero. sp (optional): The horizontal velocity
         (speed), in meters per second, that the client device is traveling.
         alt (optional): The altitude of the client device, in meters. are
         (optional): The radius, in meters, that specifies the vertical
         accuracy of the coordinates. Specify this key only if you specify the
         alt key. Although many of the keys are optional, the more information
         that you provide, the more accurate the location results are. Although
         optional, you are encouraged to always specify the user's geographical
         location. Providing the location is especially important if the
         client's IP address does not accurately reflect the user's physical
         location (for example, if the client uses VPN). For optimal results,
         you should include this header and the  X-Search-ClientIP header, but
         at a minimum, you should include this header.
        :type location: str
        :param action_type: A string that's used by logging to determine
         whether the request is coming from an interactive session or a page
         load. The following are the possible values. 1) Edit—The request is
         from an interactive session 2) Load—The request is from a page load.
         Possible values include: 'Edit', 'Load'
        :type action_type: str or
         ~azure.cognitiveservices.language.spellcheck.models.ActionType
        :param app_name: The unique name of your app. The name must be known
         by Bing. Do not include this parameter unless you have previously
         contacted Bing to get a unique app name. To get a unique name, contact
         your Bing Business Development manager.
        :type app_name: str
        :param country_code: A 2-character country code of the country where
         the results come from. This API supports only the United States
         market. If you specify this query parameter, it must be set to us. If
         you set this parameter, you must also specify the Accept-Language
         header. Bing uses the first supported language it finds from the
         languages list, and combine that language with the country code that
         you specify to determine the market to return results for. If the
         languages list does not include a supported language, Bing finds the
         closest language and market that supports the request, or it may use
         an aggregated or default market for the results instead of a specified
         one. You should use this query parameter and the Accept-Language query
         parameter only if you specify multiple languages; otherwise, you
         should use the mkt and setLang query parameters. This parameter and
         the mkt query parameter are mutually exclusive—do not specify both.
        :type country_code: str
        :param client_machine_name: A unique name of the device that the
         request is being made from. Generate a unique value for each device
         (the value is unimportant). The service uses the ID to help debug
         issues and improve the quality of corrections.
        :type client_machine_name: str
        :param doc_id: A unique ID that identifies the document that the text
         belongs to. Generate a unique value for each document (the value is
         unimportant). The service uses the ID to help debug issues and improve
         the quality of corrections.
        :type doc_id: str
        :param market: The market where the results come from. You are
         strongly encouraged to always specify the market, if known. Specifying
         the market helps Bing route the request and return an appropriate and
         optimal response. This parameter and the cc query parameter are
         mutually exclusive—do not specify both.
        :type market: str
        :param session_id: A unique ID that identifies this user session.
         Generate a unique value for each user session (the value is
         unimportant). The service uses the ID to help debug issues and improve
         the quality of corrections
        :type session_id: str
        :param set_lang: The language to use for user interface strings.
         Specify the language using the ISO 639-1 2-letter language code. For
         example, the language code for English is EN. The default is EN
         (English). Although optional, you should always specify the language.
         Typically, you set setLang to the same language specified by mkt
         unless the user wants the user interface strings displayed in a
         different language. This parameter and the Accept-Language header are
         mutually exclusive—do not specify both. A user interface string is a
         string that's used as a label in a user interface. There are few user
         interface strings in the JSON response objects. Also, any links to
         Bing.com properties in the response objects apply the specified
         language.
        :type set_lang: str
        :param user_id: A unique ID that identifies the user. Generate a
         unique value for each user (the value is unimportant). The service
         uses the ID to help debug issues and improve the quality of
         corrections.
        :type user_id: str
        :param mode: The type of spelling and grammar checks to perform. The
         following are the possible values (the values are case insensitive).
         The default is Proof. 1) Proof—Finds most spelling and grammar
         mistakes. 2) Spell—Finds most spelling mistakes but does not find some
         of the grammar errors that Proof catches (for example, capitalization
         and repeated words). Possible values include: 'Proof', 'Spell'
        :type mode: str
        :param pre_context_text: A string that gives context to the text
         string. For example, the text string petal is valid. However, if you
         set preContextText to bike, the context changes and the text string
         becomes not valid. In this case, the API suggests that you change
         petal to pedal (as in bike pedal). This text is not checked for
         grammar or spelling errors. The combined length of the text string,
         preContextText string, and postContextText string may not exceed
         10,000 characters. You may specify this parameter in the query string
         of a GET request or in the body of a POST request.
        :type pre_context_text: str
        :param post_context_text: A string that gives context to the text
         string. For example, the text string read is valid. However, if you
         set postContextText to carpet, the context changes and the text string
         becomes not valid. In this case, the API suggests that you change read
         to red (as in red carpet). This text is not checked for grammar or
         spelling errors. The combined length of the text string,
         preContextText string, and postContextText string may not exceed
         10,000 characters. You may specify this parameter in the query string
         of a GET request or in the body of a POST request.
        :type post_context_text: 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: SpellCheck or ClientRawResponse if raw=true
        :rtype: ~azure.cognitiveservices.language.spellcheck.models.SpellCheck
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.spellcheck.models.ErrorResponseException>`
        """
        x_bing_apis_sdk = "true"

        # Construct URL
        url = '/spellcheck'

        # Construct parameters
        query_parameters = {}
        if action_type is not None:
            query_parameters['ActionType'] = self._serialize.query("action_type", action_type, 'str')
        if app_name is not None:
            query_parameters['AppName'] = self._serialize.query("app_name", app_name, 'str')
        if country_code is not None:
            query_parameters['cc'] = self._serialize.query("country_code", country_code, 'str')
        if client_machine_name is not None:
            query_parameters['ClientMachineName'] = self._serialize.query("client_machine_name", client_machine_name, 'str')
        if doc_id is not None:
            query_parameters['DocId'] = self._serialize.query("doc_id", doc_id, 'str')
        if market is not None:
            query_parameters['mkt'] = self._serialize.query("market", market, 'str')
        if session_id is not None:
            query_parameters['SessionId'] = self._serialize.query("session_id", session_id, 'str')
        if set_lang is not None:
            query_parameters['SetLang'] = self._serialize.query("set_lang", set_lang, 'str')
        if user_id is not None:
            query_parameters['UserId'] = self._serialize.query("user_id", user_id, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/x-www-form-urlencoded'
        if custom_headers:
            header_parameters.update(custom_headers)
        header_parameters['X-BingApis-SDK'] = self._serialize.header("x_bing_apis_sdk", x_bing_apis_sdk, 'str')
        if accept_language is not None:
            header_parameters['Accept-Language'] = self._serialize.header("accept_language", accept_language, 'str')
        if pragma is not None:
            header_parameters['Pragma'] = self._serialize.header("pragma", pragma, 'str')
        if user_agent is not None:
            header_parameters['User-Agent'] = self._serialize.header("user_agent", user_agent, 'str')
        if client_id is not None:
            header_parameters['X-MSEdge-ClientID'] = self._serialize.header("client_id", client_id, 'str')
        if client_ip is not None:
            header_parameters['X-MSEdge-ClientIP'] = self._serialize.header("client_ip", client_ip, 'str')
        if location is not None:
            header_parameters['X-Search-Location'] = self._serialize.header("location", location, 'str')

        # Construct form data
        form_data_content = {
            'Text': text,
            'Mode': mode,
            'PreContextText': pre_context_text,
            'PostContextText': post_context_text,
        }

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

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

        deserialized = None

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

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

        return deserialized
コード例 #57
0
class NetworkManagementClient(object):
    """Network Client

    :ivar config: Configuration for client.
    :vartype config: NetworkManagementClientConfiguration

    :ivar application_gateways: ApplicationGateways operations
    :vartype application_gateways: azure.mgmt.network.v2017_06_01.operations.ApplicationGatewaysOperations
    :ivar available_endpoint_services: AvailableEndpointServices operations
    :vartype available_endpoint_services: azure.mgmt.network.v2017_06_01.operations.AvailableEndpointServicesOperations
    :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations
    :vartype express_route_circuit_authorizations: azure.mgmt.network.v2017_06_01.operations.ExpressRouteCircuitAuthorizationsOperations
    :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations
    :vartype express_route_circuit_peerings: azure.mgmt.network.v2017_06_01.operations.ExpressRouteCircuitPeeringsOperations
    :ivar express_route_circuits: ExpressRouteCircuits operations
    :vartype express_route_circuits: azure.mgmt.network.v2017_06_01.operations.ExpressRouteCircuitsOperations
    :ivar express_route_service_providers: ExpressRouteServiceProviders operations
    :vartype express_route_service_providers: azure.mgmt.network.v2017_06_01.operations.ExpressRouteServiceProvidersOperations
    :ivar load_balancers: LoadBalancers operations
    :vartype load_balancers: azure.mgmt.network.v2017_06_01.operations.LoadBalancersOperations
    :ivar load_balancer_backend_address_pools: LoadBalancerBackendAddressPools operations
    :vartype load_balancer_backend_address_pools: azure.mgmt.network.v2017_06_01.operations.LoadBalancerBackendAddressPoolsOperations
    :ivar load_balancer_frontend_ip_configurations: LoadBalancerFrontendIPConfigurations operations
    :vartype load_balancer_frontend_ip_configurations: azure.mgmt.network.v2017_06_01.operations.LoadBalancerFrontendIPConfigurationsOperations
    :ivar inbound_nat_rules: InboundNatRules operations
    :vartype inbound_nat_rules: azure.mgmt.network.v2017_06_01.operations.InboundNatRulesOperations
    :ivar load_balancer_load_balancing_rules: LoadBalancerLoadBalancingRules operations
    :vartype load_balancer_load_balancing_rules: azure.mgmt.network.v2017_06_01.operations.LoadBalancerLoadBalancingRulesOperations
    :ivar load_balancer_network_interfaces: LoadBalancerNetworkInterfaces operations
    :vartype load_balancer_network_interfaces: azure.mgmt.network.v2017_06_01.operations.LoadBalancerNetworkInterfacesOperations
    :ivar load_balancer_probes: LoadBalancerProbes operations
    :vartype load_balancer_probes: azure.mgmt.network.v2017_06_01.operations.LoadBalancerProbesOperations
    :ivar network_interfaces: NetworkInterfaces operations
    :vartype network_interfaces: azure.mgmt.network.v2017_06_01.operations.NetworkInterfacesOperations
    :ivar network_interface_ip_configurations: NetworkInterfaceIPConfigurations operations
    :vartype network_interface_ip_configurations: azure.mgmt.network.v2017_06_01.operations.NetworkInterfaceIPConfigurationsOperations
    :ivar network_interface_load_balancers: NetworkInterfaceLoadBalancers operations
    :vartype network_interface_load_balancers: azure.mgmt.network.v2017_06_01.operations.NetworkInterfaceLoadBalancersOperations
    :ivar network_security_groups: NetworkSecurityGroups operations
    :vartype network_security_groups: azure.mgmt.network.v2017_06_01.operations.NetworkSecurityGroupsOperations
    :ivar security_rules: SecurityRules operations
    :vartype security_rules: azure.mgmt.network.v2017_06_01.operations.SecurityRulesOperations
    :ivar default_security_rules: DefaultSecurityRules operations
    :vartype default_security_rules: azure.mgmt.network.v2017_06_01.operations.DefaultSecurityRulesOperations
    :ivar network_watchers: NetworkWatchers operations
    :vartype network_watchers: azure.mgmt.network.v2017_06_01.operations.NetworkWatchersOperations
    :ivar packet_captures: PacketCaptures operations
    :vartype packet_captures: azure.mgmt.network.v2017_06_01.operations.PacketCapturesOperations
    :ivar public_ip_addresses: PublicIPAddresses operations
    :vartype public_ip_addresses: azure.mgmt.network.v2017_06_01.operations.PublicIPAddressesOperations
    :ivar route_filters: RouteFilters operations
    :vartype route_filters: azure.mgmt.network.v2017_06_01.operations.RouteFiltersOperations
    :ivar route_filter_rules: RouteFilterRules operations
    :vartype route_filter_rules: azure.mgmt.network.v2017_06_01.operations.RouteFilterRulesOperations
    :ivar route_tables: RouteTables operations
    :vartype route_tables: azure.mgmt.network.v2017_06_01.operations.RouteTablesOperations
    :ivar routes: Routes operations
    :vartype routes: azure.mgmt.network.v2017_06_01.operations.RoutesOperations
    :ivar bgp_service_communities: BgpServiceCommunities operations
    :vartype bgp_service_communities: azure.mgmt.network.v2017_06_01.operations.BgpServiceCommunitiesOperations
    :ivar usages: Usages operations
    :vartype usages: azure.mgmt.network.v2017_06_01.operations.UsagesOperations
    :ivar virtual_networks: VirtualNetworks operations
    :vartype virtual_networks: azure.mgmt.network.v2017_06_01.operations.VirtualNetworksOperations
    :ivar subnets: Subnets operations
    :vartype subnets: azure.mgmt.network.v2017_06_01.operations.SubnetsOperations
    :ivar virtual_network_peerings: VirtualNetworkPeerings operations
    :vartype virtual_network_peerings: azure.mgmt.network.v2017_06_01.operations.VirtualNetworkPeeringsOperations
    :ivar virtual_network_gateways: VirtualNetworkGateways operations
    :vartype virtual_network_gateways: azure.mgmt.network.v2017_06_01.operations.VirtualNetworkGatewaysOperations
    :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations
    :vartype virtual_network_gateway_connections: azure.mgmt.network.v2017_06_01.operations.VirtualNetworkGatewayConnectionsOperations
    :ivar local_network_gateways: LocalNetworkGateways operations
    :vartype local_network_gateways: azure.mgmt.network.v2017_06_01.operations.LocalNetworkGatewaysOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param subscription_id: The subscription credentials which uniquely
     identify the Microsoft Azure subscription. The subscription ID forms part
     of the URI for every service call.
    :type subscription_id: str
    :param str base_url: Service URL
    """
    def __init__(self, credentials, subscription_id, base_url=None):

        self.config = NetworkManagementClientConfiguration(
            credentials, subscription_id, base_url)
        self._client = ServiceClient(self.config.credentials, self.config)

        client_models = {
            k: v
            for k, v in models.__dict__.items() if isinstance(v, type)
        }
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.application_gateways = ApplicationGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.available_endpoint_services = AvailableEndpointServicesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_circuits = ExpressRouteCircuitsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.express_route_service_providers = ExpressRouteServiceProvidersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancers = LoadBalancersOperations(self._client,
                                                      self.config,
                                                      self._serialize,
                                                      self._deserialize)
        self.load_balancer_backend_address_pools = LoadBalancerBackendAddressPoolsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_frontend_ip_configurations = LoadBalancerFrontendIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.inbound_nat_rules = InboundNatRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_load_balancing_rules = LoadBalancerLoadBalancingRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_network_interfaces = LoadBalancerNetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.load_balancer_probes = LoadBalancerProbesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interfaces = NetworkInterfacesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_ip_configurations = NetworkInterfaceIPConfigurationsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_interface_load_balancers = NetworkInterfaceLoadBalancersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_security_groups = NetworkSecurityGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.security_rules = SecurityRulesOperations(self._client,
                                                      self.config,
                                                      self._serialize,
                                                      self._deserialize)
        self.default_security_rules = DefaultSecurityRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.network_watchers = NetworkWatchersOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.packet_captures = PacketCapturesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.public_ip_addresses = PublicIPAddressesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_filters = RouteFiltersOperations(self._client, self.config,
                                                    self._serialize,
                                                    self._deserialize)
        self.route_filter_rules = RouteFilterRulesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.route_tables = RouteTablesOperations(self._client, self.config,
                                                  self._serialize,
                                                  self._deserialize)
        self.routes = RoutesOperations(self._client, self.config,
                                       self._serialize, self._deserialize)
        self.bgp_service_communities = BgpServiceCommunitiesOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.usages = UsagesOperations(self._client, self.config,
                                       self._serialize, self._deserialize)
        self.virtual_networks = VirtualNetworksOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.subnets = SubnetsOperations(self._client, self.config,
                                         self._serialize, self._deserialize)
        self.virtual_network_peerings = VirtualNetworkPeeringsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateways = VirtualNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.local_network_gateways = LocalNetworkGatewaysOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_dns_name_availability(self,
                                    location,
                                    domain_name_label=None,
                                    custom_headers=None,
                                    raw=False,
                                    **operation_config):
        """Checks whether a domain name in the cloudapp.net zone is available for
        use.

        :param location: The location of the domain name.
        :type location: str
        :param domain_name_label: The domain name to be verified. It must
         conform to the following regular expression:
         ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
        :type domain_name_label: 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: :class:`DnsNameAvailabilityResult
         <azure.mgmt.network.v2017_06_01.models.DnsNameAvailabilityResult>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
         raw=true
        :rtype: :class:`DnsNameAvailabilityResult
         <azure.mgmt.network.v2017_06_01.models.DnsNameAvailabilityResult>` or
         :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        api_version = "2017-06-01"

        # Construct URL
        url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'
        path_format_arguments = {
            'location':
            self._serialize.url("location", location, '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 = {}
        if domain_name_label is not None:
            query_parameters['domainNameLabel'] = self._serialize.query(
                "domain_name_label", domain_name_label, 'str')
        query_parameters['api-version'] = self._serialize.query(
            "api_version", 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,
                                     **operation_config)

        if response.status_code not in [200]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        deserialized = None

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

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

        return deserialized
コード例 #58
0
class ManagementGroupsAPI(SDKClient):
    """The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources.

    :ivar config: Configuration for client.
    :vartype config: ManagementGroupsAPIConfiguration

    :ivar management_groups: ManagementGroups operations
    :vartype management_groups: azure.mgmt.managementgroups.operations.ManagementGroupsOperations
    :ivar management_group_subscriptions: ManagementGroupSubscriptions operations
    :vartype management_group_subscriptions: azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations
    :ivar operations: Operations operations
    :vartype operations: azure.mgmt.managementgroups.operations.Operations
    :ivar entities: Entities operations
    :vartype entities: azure.mgmt.managementgroups.operations.EntitiesOperations

    :param credentials: Credentials needed for the client to connect to Azure.
    :type credentials: :mod:`A msrestazure Credentials
     object<msrestazure.azure_active_directory>`
    :param str base_url: Service URL
    """

    def __init__(
            self, credentials, base_url=None):

        self.config = ManagementGroupsAPIConfiguration(credentials, base_url)
        super(ManagementGroupsAPI, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = '2018-03-01-preview'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)

        self.management_groups = ManagementGroupsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.management_group_subscriptions = ManagementGroupSubscriptionsOperations(
            self._client, self.config, self._serialize, self._deserialize)
        self.operations = Operations(
            self._client, self.config, self._serialize, self._deserialize)
        self.entities = EntitiesOperations(
            self._client, self.config, self._serialize, self._deserialize)

    def check_name_availability(
            self, check_name_availability_request, custom_headers=None, raw=False, **operation_config):
        """Checks if the specified management group name is valid and unique.

        :param check_name_availability_request: Management group name
         availability check parameters.
        :type check_name_availability_request:
         ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest
        :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: CheckNameAvailabilityResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult or
         ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.managementgroups.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.check_name_availability.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct body
        body_content = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest')

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

        deserialized = None

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

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

        return deserialized
    check_name_availability.metadata = {'url': '/providers/Microsoft.Management/checkNameAvailability'}

    def start_tenant_backfill(
            self, custom_headers=None, raw=False, **operation_config):
        """Starts backfilling subscriptions for the Tenant.

        :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: TenantBackfillStatusResult or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.managementgroups.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.start_tenant_backfill.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.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)

        deserialized = None

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

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

        return deserialized
    start_tenant_backfill.metadata = {'url': '/providers/Microsoft.Management/startTenantBackfill'}

    def tenant_backfill_status(
            self, custom_headers=None, raw=False, **operation_config):
        """Gets tenant backfill status.

        :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: TenantBackfillStatusResult or ClientRawResponse if raw=true
        :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.mgmt.managementgroups.models.ErrorResponseException>`
        """
        # Construct URL
        url = self.tenant_backfill_status.metadata['url']

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        header_parameters['Accept'] = 'application/json'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.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)

        deserialized = None

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

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

        return deserialized
    tenant_backfill_status.metadata = {'url': '/providers/Microsoft.Management/tenantBackfillStatus'}
コード例 #59
0
class TextAnalyticsClient(SDKClient):
    """The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. No training data is needed to use this API; just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview

    :ivar config: Configuration for client.
    :vartype config: TextAnalyticsClientConfiguration

    :param endpoint: Supported Cognitive Services endpoints (protocol and
     hostname, for example: https://westus.api.cognitive.microsoft.com).
    :type endpoint: str
    :param credentials: Subscription credentials which uniquely identify
     client subscription.
    :type credentials: None
    """

    def __init__(
            self, endpoint, credentials):

        self.config = TextAnalyticsClientConfiguration(endpoint, credentials)
        super(TextAnalyticsClient, self).__init__(self.config.credentials, self.config)

        client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
        self.api_version = 'v2.1'
        self._serialize = Serializer(client_models)
        self._deserialize = Deserializer(client_models)


    def detect_language(
            self, show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config):
        """The API returns the detected language and a numeric score between 0 and
        1.

        Scores close to 1 indicate 100% certainty that the identified language
        is true. A total of 120 languages are supported.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.LanguageInput]
        :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: LanguageBatchResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.textanalytics.models.LanguageBatchResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>`
        """
        language_batch_input = None
        if documents is not None:
            language_batch_input = models.LanguageBatchInput(documents=documents)

        # Construct URL
        url = self.detect_language.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query("show_stats", show_stats, 'bool')

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

        # Construct body
        if language_batch_input is not None:
            body_content = self._serialize.body(language_batch_input, 'LanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

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

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

        return deserialized
    detect_language.metadata = {'url': '/languages'}

    def entities(
            self, show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config):
        """The API returns a list of recognized entities in a given document.

        To get even more information on each recognized entity we recommend
        using the Bing Entity Search API by querying for the recognized
        entities names. See the <a
        href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported
        languages in Text Analytics API</a> for the list of enabled languages.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput]
        :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: EntitiesBatchResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.textanalytics.models.EntitiesBatchResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>`
        """
        multi_language_batch_input = None
        if documents is not None:
            multi_language_batch_input = models.MultiLanguageBatchInput(documents=documents)

        # Construct URL
        url = self.entities.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query("show_stats", show_stats, 'bool')

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

        # Construct body
        if multi_language_batch_input is not None:
            body_content = self._serialize.body(multi_language_batch_input, 'MultiLanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

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

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

        return deserialized
    entities.metadata = {'url': '/entities'}

    def key_phrases(
            self, show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config):
        """The API returns a list of strings denoting the key talking points in
        the input text.

        See the <a
        href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text
        Analytics Documentation</a> for details about the languages that are
        supported by key phrase extraction.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput]
        :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: KeyPhraseBatchResult or ClientRawResponse if raw=true
        :rtype:
         ~azure.cognitiveservices.language.textanalytics.models.KeyPhraseBatchResult
         or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>`
        """
        multi_language_batch_input = None
        if documents is not None:
            multi_language_batch_input = models.MultiLanguageBatchInput(documents=documents)

        # Construct URL
        url = self.key_phrases.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query("show_stats", show_stats, 'bool')

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

        # Construct body
        if multi_language_batch_input is not None:
            body_content = self._serialize.body(multi_language_batch_input, 'MultiLanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

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

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

        return deserialized
    key_phrases.metadata = {'url': '/keyPhrases'}

    def sentiment(
            self, show_stats=None, documents=None, custom_headers=None, raw=False, **operation_config):
        """The API returns a numeric score between 0 and 1.

        Scores close to 1 indicate positive sentiment, while scores close to 0
        indicate negative sentiment. A score of 0.5 indicates the lack of
        sentiment (e.g. a factoid statement). See the <a
        href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text
        Analytics Documentation</a> for details about the languages that are
        supported by sentiment analysis.

        :param show_stats: (optional) if set to true, response will contain
         input and document level statistics.
        :type show_stats: bool
        :param documents:
        :type documents:
         list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput]
        :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: object or ClientRawResponse if raw=true
        :rtype: object or ~msrest.pipeline.ClientRawResponse
        :raises:
         :class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
        """
        multi_language_batch_input = None
        if documents is not None:
            multi_language_batch_input = models.MultiLanguageBatchInput(documents=documents)

        # Construct URL
        url = self.sentiment.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 show_stats is not None:
            query_parameters['showStats'] = self._serialize.query("show_stats", show_stats, 'bool')

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

        # Construct body
        if multi_language_batch_input is not None:
            body_content = self._serialize.body(multi_language_batch_input, 'MultiLanguageBatchInput')
        else:
            body_content = None

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

        deserialized = None

        if response.status_code == 200:
            deserialized = self._deserialize('SentimentBatchResult', response)
        if response.status_code == 500:
            deserialized = self._deserialize('ErrorResponse', response)

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

        return deserialized
    sentiment.metadata = {'url': '/sentiment'}