def sample_delete_entity_type():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    request = dialogflow_v2.DeleteEntityTypeRequest(name="name_value", )

    # Make the request
    client.delete_entity_type(request=request)
def sample_get_entity_type():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    request = dialogflow_v2.GetEntityTypeRequest(name="name_value", )

    # Make the request
    response = client.get_entity_type(request=request)

    # Handle the response
    print(response)
def sample_list_entity_types():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    request = dialogflow_v2.ListEntityTypesRequest(parent="parent_value", )

    # Make the request
    page_result = client.list_entity_types(request=request)

    # Handle the response
    for response in page_result:
        print(response)
def sample_update_entity_type():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    entity_type = dialogflow_v2.EntityType()
    entity_type.display_name = "display_name_value"
    entity_type.kind = "KIND_REGEXP"

    request = dialogflow_v2.UpdateEntityTypeRequest(entity_type=entity_type, )

    # Make the request
    response = client.update_entity_type(request=request)

    # Handle the response
    print(response)
def sample_delete_entity_type(project_id, entity_type_id):
    """Delete Entity Type"""

    # [START dialogflow_delete_entity_type_core]

    client = dialogflow_v2.EntityTypesClient()

    # project_id = 'Your Google Cloud Project ID'
    # entity_type_id = 'ID of the EntityType to delete'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(entity_type_id, six.binary_type):
        entity_type_id = entity_type_id.decode('utf-8')
    name = client.entity_type_path(project_id, entity_type_id)

    client.delete_entity_type(name)
    print('Deleted EntityType')
def sample_list_entity_types(project_id):
    """List Entity Types"""

    # [START dialogflow_list_entity_types_core]

    client = dialogflow_v2.EntityTypesClient()

    # project_id = 'Your Google Cloud Project ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode('utf-8')
    parent = client.project_agent_path(project_id)

    # Iterate over all results
    for response_item in client.list_entity_types(parent):
        print('Entity type name: {}'.format(response_item.name))
        print('Entity type display name: {}'.format(
            response_item.display_name))
def sample_batch_update_entity_types():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    request = dialogflow_v2.BatchUpdateEntityTypesRequest(
        entity_type_batch_uri="entity_type_batch_uri_value",
        parent="parent_value",
    )

    # Make the request
    operation = client.batch_update_entity_types(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
def sample_batch_delete_entity_types():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    request = dialogflow_v2.BatchDeleteEntityTypesRequest(
        parent="parent_value",
        entity_type_names=['entity_type_names_value_1', 'entity_type_names_value_2'],
    )

    # Make the request
    operation = client.batch_delete_entity_types(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
def sample_create_entity_type(project_id, display_name):
    """Create Entity Type"""

    # [START dialogflow_create_entity_type_core]

    client = dialogflow_v2.EntityTypesClient()

    # project_id = 'Your Google Cloud Project ID'
    # display_name = 'Display name of Entity Type'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode('utf-8')
    if isinstance(display_name, six.binary_type):
        display_name = display_name.decode('utf-8')
    parent = client.project_agent_path(project_id)
    kind = enums.EntityType.Kind.KIND_MAP
    entity_type = {'display_name': display_name, 'kind': kind}

    response = client.create_entity_type(parent, entity_type)
    print('Created new entity type: {}'.format(response.name))
Exemple #10
0
def create_entity(project_id, entity_type_id, entity_value, synonyms):
    """Create an entity of the given entity type."""
    # import dialogflow_v2 as dialogflow
    entity_types_client = dialogflow.EntityTypesClient()

    # Note: synonyms must be exactly [entity_value] if the
    # entity_type's kind is KIND_LIST
    synonyms = synonyms or [entity_value]

    entity_type_path = entity_types_client.entity_type_path(
        project_id, entity_type_id)

    entity = dialogflow.types.EntityType.Entity()
    entity.value = entity_value
    entity.synonyms.extend(synonyms)

    response = entity_types_client.batch_create_entities(
        parent=entity_type_path, entities=[entity])

    print('Entity created: {}'.format(response))
Exemple #11
0
def sample_batch_update_entities():
    # Create a client
    client = dialogflow_v2.EntityTypesClient()

    # Initialize request argument(s)
    entities = dialogflow_v2.Entity()
    entities.value = "value_value"
    entities.synonyms = ['synonyms_value_1', 'synonyms_value_2']

    request = dialogflow_v2.BatchUpdateEntitiesRequest(
        parent="parent_value",
        entities=entities,
    )

    # Make the request
    operation = client.batch_update_entities(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)