Created
April 12, 2018 18:38
-
-
Save beccasaurus/0f683cb63e35d15d12f2f15c1fd8ace5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Google.Cloud.Dialogflow.V2; | |
// To setup, follow instructions: | |
// https://cloud.google.com/dialogflow-enterprise/docs/quickstart-client-libraries | |
namespace GoogleCloudSamples | |
{ | |
public class EntityTypeManagement | |
{ | |
public void Create(string projectId, string displayName, EntityType.Types.Kind kind = EntityType.Types.Kind.Map) | |
{ | |
var client = EntityTypesClient.Create(); | |
var entityType = new EntityType(); | |
entityType.DisplayName = displayName; | |
entityType.Kind = kind; | |
var createdEntityType = client.CreateEntityType( | |
parent: new ProjectAgentName(projectId), | |
entityType: entityType | |
); | |
Console.WriteLine($"Created entity type: {createdEntityType.Name}"); | |
} | |
public void List(string projectId) | |
{ | |
var client = EntityTypesClient.Create(); | |
var response = client.ListEntityTypes(parent: new ProjectAgentName(projectId)); | |
foreach (var entityType in response) | |
{ | |
Console.WriteLine($"Entity name: {entityType.Name}"); | |
Console.WriteLine($"Entity display name: {entityType.DisplayName}"); | |
Console.WriteLine($"Number of entities: {entityType.Entities.Count}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment