// [START dialogflow_create_session_entity_type]
        public static int Create(string projectId,
                                 string sessionId,
                                 string entityTypeDisplayName,
                                 string[] entityValues)
        {
            var client = SessionEntityTypesClient.Create();

            var sessionEntityType = new SessionEntityType();

            sessionEntityType.SessionEntityTypeName = new SessionEntityTypeName(projectId, sessionId, entityTypeDisplayName);
            sessionEntityType.EntityOverrideMode    = SessionEntityType.Types.EntityOverrideMode.Override;
            foreach (var entityValue in entityValues)
            {
                var entity = new EntityType.Types.Entity()
                {
                    Value = entityValue
                };
                entity.Synonyms.Add(entityValue);
                sessionEntityType.Entities.Add(entity);
            }

            var createdSessionEntityType = client.CreateSessionEntityType(
                parent: new SessionName(projectId, sessionId),
                sessionEntityType: sessionEntityType
                );

            Console.WriteLine($"Created SessionEntityType: {createdSessionEntityType.Name}");

            return(0);
        }
Esempio n. 2
0
 /// <summary>Snippet for GetSessionEntityType</summary>
 public void GetSessionEntityType()
 {
     // Snippet: GetSessionEntityType(string, CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/sessions/[SESSION]/entityTypes/[ENTITY_TYPE]";
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.GetSessionEntityType(name);
     // End snippet
 }
 /// <summary>Snippet for GetSessionEntityType</summary>
 public void GetSessionEntityType()
 {
     // Snippet: GetSessionEntityType(SessionEntityTypeName,CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     SessionEntityTypeName name = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.GetSessionEntityType(name);
     // End snippet
 }
 /// <summary>Snippet for UpdateSessionEntityType</summary>
 public void UpdateSessionEntityType()
 {
     // Snippet: UpdateSessionEntityType(SessionEntityType,CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     SessionEntityType sessionEntityType = new SessionEntityType();
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.UpdateSessionEntityType(sessionEntityType);
     // End snippet
 }
Esempio n. 5
0
 /// <summary>Snippet for GetSessionEntityType</summary>
 public void GetSessionEntityTypeResourceNames()
 {
     // Snippet: GetSessionEntityType(SessionEntityTypeName, CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     SessionEntityTypeName name = SessionEntityTypeName.FromProjectLocationAgentSessionEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]", "[ENTITY_TYPE]");
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.GetSessionEntityType(name);
     // End snippet
 }
Esempio n. 6
0
 /// <summary>Snippet for CreateSessionEntityType</summary>
 public void CreateSessionEntityType()
 {
     // Snippet: CreateSessionEntityType(string, SessionEntityType, CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     string            parent            = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/sessions/[SESSION]";
     SessionEntityType sessionEntityType = new SessionEntityType();
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.CreateSessionEntityType(parent, sessionEntityType);
     // End snippet
 }
Esempio n. 7
0
 /// <summary>Snippet for CreateSessionEntityType</summary>
 public void CreateSessionEntityType()
 {
     // Snippet: CreateSessionEntityType(string, SessionEntityType, CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     string            parent            = "";
     SessionEntityType sessionEntityType = new SessionEntityType();
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.CreateSessionEntityType(parent, sessionEntityType);
     // End snippet
 }
 /// <summary>Snippet for CreateSessionEntityType</summary>
 public void CreateSessionEntityType()
 {
     // Snippet: CreateSessionEntityType(SessionName,SessionEntityType,CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     SessionName       parent            = new SessionName("[PROJECT]", "[SESSION]");
     SessionEntityType sessionEntityType = new SessionEntityType();
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.CreateSessionEntityType(parent, sessionEntityType);
     // End snippet
 }
        // [START dialogflow_delete_session_entity_type]
        public static int Delete(string projectId, string sessionId, string entityTypeDisplayName)
        {
            var client = SessionEntityTypesClient.Create();

            client.DeleteSessionEntityType(new SessionEntityTypeName(
                                               projectId, sessionId, entityTypeDisplayName
                                               ));

            Console.WriteLine($"Deleted SessionEntityType: {entityTypeDisplayName}");

            return(0);
        }
Esempio n. 10
0
        /// <summary>Snippet for DeleteSessionEntityType</summary>
        public void DeleteSessionEntityTypeResourceNames()
        {
            // Snippet: DeleteSessionEntityType(SessionEntityTypeName, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            SessionEntityTypeName name = SessionEntityTypeName.FromProjectSessionEntityType("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");

            // Make the request
            sessionEntityTypesClient.DeleteSessionEntityType(name);
            // End snippet
        }
Esempio n. 11
0
        /// <summary>Snippet for DeleteSessionEntityType</summary>
        public void DeleteSessionEntityType()
        {
            // Snippet: DeleteSessionEntityType(string, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/agent/sessions/[SESSION]/entityTypes/[ENTITY_TYPE]";

            // Make the request
            sessionEntityTypesClient.DeleteSessionEntityType(name);
            // End snippet
        }
Esempio n. 12
0
 /// <summary>Snippet for CreateSessionEntityType</summary>
 public void CreateSessionEntityTypeResourceNames()
 {
     // Snippet: CreateSessionEntityType(SessionName, SessionEntityType, CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     SessionName       parent            = SessionName.FromProjectLocationAgentSession("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]");
     SessionEntityType sessionEntityType = new SessionEntityType();
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.CreateSessionEntityType(parent, sessionEntityType);
     // End snippet
 }
 /// <summary>Snippet for UpdateSessionEntityType</summary>
 public void UpdateSessionEntityType_RequestObject()
 {
     // Snippet: UpdateSessionEntityType(UpdateSessionEntityTypeRequest,CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     UpdateSessionEntityTypeRequest request = new UpdateSessionEntityTypeRequest
     {
         SessionEntityType = new SessionEntityType(),
     };
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.UpdateSessionEntityType(request);
     // End snippet
 }
 /// <summary>Snippet for GetSessionEntityType</summary>
 public void GetSessionEntityType_RequestObject()
 {
     // Snippet: GetSessionEntityType(GetSessionEntityTypeRequest,CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     GetSessionEntityTypeRequest request = new GetSessionEntityTypeRequest
     {
         SessionEntityTypeName = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
     };
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.GetSessionEntityType(request);
     // End snippet
 }
Esempio n. 15
0
        /// <summary>Snippet for DeleteSessionEntityType</summary>
        public void DeleteSessionEntityTypeRequestObject()
        {
            // Snippet: DeleteSessionEntityType(DeleteSessionEntityTypeRequest, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            DeleteSessionEntityTypeRequest request = new DeleteSessionEntityTypeRequest
            {
                ContextName = ContextName.FromProjectSessionContext("[PROJECT]", "[SESSION]", "[CONTEXT]"),
            };

            // Make the request
            sessionEntityTypesClient.DeleteSessionEntityType(request);
            // End snippet
        }
 /// <summary>Snippet for CreateSessionEntityType</summary>
 public void CreateSessionEntityType_RequestObject()
 {
     // Snippet: CreateSessionEntityType(CreateSessionEntityTypeRequest,CallSettings)
     // Create client
     SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
     // Initialize request argument(s)
     CreateSessionEntityTypeRequest request = new CreateSessionEntityTypeRequest
     {
         ParentAsSessionName = new SessionName("[PROJECT]", "[SESSION]"),
         SessionEntityType   = new SessionEntityType(),
     };
     // Make the request
     SessionEntityType response = sessionEntityTypesClient.CreateSessionEntityType(request);
     // End snippet
 }
Esempio n. 17
0
        /// <summary>Snippet for DeleteSessionEntityType</summary>
        public void DeleteSessionEntityTypeRequestObject()
        {
            // Snippet: DeleteSessionEntityType(DeleteSessionEntityTypeRequest, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            DeleteSessionEntityTypeRequest request = new DeleteSessionEntityTypeRequest
            {
                SessionEntityTypeName = SessionEntityTypeName.FromProjectLocationAgentSessionEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]", "[ENTITY_TYPE]"),
            };

            // Make the request
            sessionEntityTypesClient.DeleteSessionEntityType(request);
            // End snippet
        }
Esempio n. 18
0
        /// <summary>Snippet for ListSessionEntityTypes</summary>
        public void ListSessionEntityTypesRequestObject()
        {
            // Snippet: ListSessionEntityTypes(ListSessionEntityTypesRequest, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            ListSessionEntityTypesRequest request = new ListSessionEntityTypesRequest
            {
                ParentAsSessionName = SessionName.FromProjectLocationAgentSession("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]"),
            };
            // Make the request
            PagedEnumerable <ListSessionEntityTypesResponse, SessionEntityType> response = sessionEntityTypesClient.ListSessionEntityTypes(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (SessionEntityType item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListSessionEntityTypesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (SessionEntityType item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <SessionEntityType> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (SessionEntityType item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Esempio n. 19
0
        /// <summary>Snippet for ListSessionEntityTypes</summary>
        public void ListSessionEntityTypes()
        {
            // Snippet: ListSessionEntityTypes(string, string, int?, CallSettings)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = SessionEntityTypesClient.Create();
            // Initialize request argument(s)
            string parent = "";
            // Make the request
            PagedEnumerable <ListSessionEntityTypesResponse, SessionEntityType> response = sessionEntityTypesClient.ListSessionEntityTypes(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (SessionEntityType item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListSessionEntityTypesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (SessionEntityType item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <SessionEntityType> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (SessionEntityType item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        // [START dialogflow_list_session_entity_types]
        public static int List(string projectId, string sessionId)
        {
            var client   = SessionEntityTypesClient.Create();
            var response = client.ListSessionEntityTypes(
                parent: new SessionName(projectId, sessionId)
                );

            foreach (var sessionEntityType in response)
            {
                Console.WriteLine($"SessionEntityType name: {sessionEntityType.Name}");
                Console.WriteLine($"Number of entities: {sessionEntityType.Entities.Count}");
                if (sessionEntityType.Entities.Count > 0)
                {
                    Console.WriteLine("Entity values:");
                    foreach (var entity in sessionEntityType.Entities)
                    {
                        Console.WriteLine(entity.Value);
                    }
                }
            }

            return(0);
        }