Source code for azure.cognitiveservices.language.luis.authoring.operations._examples_operations

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

from msrest.pipeline import ClientRawResponse

from .. import models


[docs]class ExamplesOperations(object): """ExamplesOperations operations. You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = models def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self.config = config
[docs] def add( self, app_id, version_id, example_label_object, enable_nested_children=False, custom_headers=None, raw=False, **operation_config): """Adds a labeled example utterance in a version of the application. :param app_id: The application ID. :type app_id: str :param version_id: The version ID. :type version_id: str :param example_label_object: A labeled example utterance with the expected intent and entities. :type example_label_object: ~azure.cognitiveservices.language.luis.authoring.models.ExampleLabelObject :param enable_nested_children: Toggles nested/flat format :type enable_nested_children: 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: LabelExampleResponse or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.luis.authoring.models.LabelExampleResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.luis.authoring.models.ErrorResponseException>` """ # Construct URL url = self.add.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'appId': self._serialize.url("app_id", app_id, 'str'), 'versionId': self._serialize.url("version_id", version_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if enable_nested_children is not None: query_parameters['enableNestedChildren'] = self._serialize.query("enable_nested_children", enable_nested_children, '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 body_content = self._serialize.body(example_label_object, 'ExampleLabelObject') # 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 [201]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 201: deserialized = self._deserialize('LabelExampleResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
add.metadata = {'url': '/apps/{appId}/versions/{versionId}/example'}
[docs] def batch( self, app_id, version_id, example_label_object_array, enable_nested_children=False, custom_headers=None, raw=False, **operation_config): """Adds a batch of labeled example utterances to a version of the application. :param app_id: The application ID. :type app_id: str :param version_id: The version ID. :type version_id: str :param example_label_object_array: Array of example utterances. :type example_label_object_array: list[~azure.cognitiveservices.language.luis.authoring.models.ExampleLabelObject] :param enable_nested_children: Toggles nested/flat format :type enable_nested_children: 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: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.language.luis.authoring.models.BatchLabelExample] or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.luis.authoring.models.ErrorResponseException>` """ # Construct URL url = self.batch.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'appId': self._serialize.url("app_id", app_id, 'str'), 'versionId': self._serialize.url("version_id", version_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if enable_nested_children is not None: query_parameters['enableNestedChildren'] = self._serialize.query("enable_nested_children", enable_nested_children, '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 body_content = self._serialize.body(example_label_object_array, '[ExampleLabelObject]') # 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 [201, 207]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 201: deserialized = self._deserialize('[BatchLabelExample]', response) if response.status_code == 207: deserialized = self._deserialize('[BatchLabelExample]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
batch.metadata = {'url': '/apps/{appId}/versions/{versionId}/examples'}
[docs] def list( self, app_id, version_id, skip=0, take=100, enable_nested_children=False, custom_headers=None, raw=False, **operation_config): """Returns example utterances to be reviewed from a version of the application. :param app_id: The application ID. :type app_id: str :param version_id: The version ID. :type version_id: str :param skip: The number of entries to skip. Default value is 0. :type skip: int :param take: The number of entries to return. Maximum page size is 500. Default is 100. :type take: int :param enable_nested_children: Toggles nested/flat format :type enable_nested_children: 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: list or ClientRawResponse if raw=true :rtype: list[~azure.cognitiveservices.language.luis.authoring.models.LabeledUtterance] or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.luis.authoring.models.ErrorResponseException>` """ # Construct URL url = self.list.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'appId': self._serialize.url("app_id", app_id, 'str'), 'versionId': self._serialize.url("version_id", version_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if skip is not None: query_parameters['skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if take is not None: query_parameters['take'] = self._serialize.query("take", take, 'int', maximum=500, minimum=0) if enable_nested_children is not None: query_parameters['enableNestedChildren'] = self._serialize.query("enable_nested_children", enable_nested_children, 'bool') # 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('[LabeledUtterance]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
list.metadata = {'url': '/apps/{appId}/versions/{versionId}/examples'}
[docs] def delete( self, app_id, version_id, example_id, custom_headers=None, raw=False, **operation_config): """Deletes the labeled example utterances with the specified ID from a version of the application. :param app_id: The application ID. :type app_id: str :param version_id: The version ID. :type version_id: str :param example_id: The example ID. :type example_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: OperationStatus or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.luis.authoring.models.OperationStatus or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.luis.authoring.models.ErrorResponseException>` """ # Construct URL url = self.delete.metadata['url'] path_format_arguments = { 'Endpoint': self._serialize.url("self.config.endpoint", self.config.endpoint, 'str', skip_quote=True), 'appId': self._serialize.url("app_id", app_id, 'str'), 'versionId': self._serialize.url("version_id", version_id, 'str'), 'exampleId': self._serialize.url("example_id", example_id, 'int') } 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.delete(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('OperationStatus', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
delete.metadata = {'url': '/apps/{appId}/versions/{versionId}/examples/{exampleId}'}