// [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);
        }
Beispiel #2
0
        public void UpdateSessionEntityType()
        {
            moq::Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new moq::Mock <SessionEntityTypes.SessionEntityTypesClient>(moq::MockBehavior.Strict);
            UpdateSessionEntityTypeRequest request = new UpdateSessionEntityTypeRequest
            {
                SessionEntityType = new SessionEntityType(),
                UpdateMask        = new wkt::FieldMask(),
            };
            SessionEntityType expectedResponse = new SessionEntityType
            {
                SessionEntityTypeName = SessionEntityTypeName.FromProjectLocationAgentSessionEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]", "[ENTITY_TYPE]"),
                EntityOverrideMode    = SessionEntityType.Types.EntityOverrideMode.Supplement,
                Entities =
                {
                    new EntityType.Types.Entity(),
                },
            };

            mockGrpcClient.Setup(x => x.UpdateSessionEntityType(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SessionEntityTypesClient client   = new SessionEntityTypesClientImpl(mockGrpcClient.Object, null);
            SessionEntityType        response = client.UpdateSessionEntityType(request.SessionEntityType, request.UpdateMask);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #3
0
        public async stt::Task GetSessionEntityTypeRequestObjectAsync()
        {
            moq::Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new moq::Mock <SessionEntityTypes.SessionEntityTypesClient>(moq::MockBehavior.Strict);
            GetSessionEntityTypeRequest request = new GetSessionEntityTypeRequest
            {
                SessionEntityTypeName = SessionEntityTypeName.FromProjectSessionEntityType("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
            };
            SessionEntityType expectedResponse = new SessionEntityType
            {
                SessionEntityTypeName = SessionEntityTypeName.FromProjectSessionEntityType("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
                EntityOverrideMode    = SessionEntityType.Types.EntityOverrideMode.Supplement,
                Entities =
                {
                    new EntityType.Types.Entity(),
                },
            };

            mockGrpcClient.Setup(x => x.GetSessionEntityTypeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SessionEntityType>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            SessionEntityTypesClient client = new SessionEntityTypesClientImpl(mockGrpcClient.Object, null);
            SessionEntityType        responseCallSettings = await client.GetSessionEntityTypeAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            SessionEntityType responseCancellationToken = await client.GetSessionEntityTypeAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #4
0
        public void CreateSessionEntityTypeRequestObject()
        {
            moq::Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new moq::Mock <SessionEntityTypes.SessionEntityTypesClient>(moq::MockBehavior.Strict);
            CreateSessionEntityTypeRequest request = new CreateSessionEntityTypeRequest
            {
                Parent            = "parent7858e4d0",
                SessionEntityType = new SessionEntityType(),
            };
            SessionEntityType expectedResponse = new SessionEntityType
            {
                SessionEntityTypeName = SessionEntityTypeName.FromProjectSessionEntityType("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
                EntityOverrideMode    = SessionEntityType.Types.EntityOverrideMode.Supplement,
                Entities =
                {
                    new EntityType.Types.Entity(),
                },
            };

            mockGrpcClient.Setup(x => x.CreateSessionEntityType(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SessionEntityTypesClient client   = new SessionEntityTypesClientImpl(mockGrpcClient.Object, null);
            SessionEntityType        response = client.CreateSessionEntityType(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #5
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
 }
Beispiel #8
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
 }
Beispiel #9
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
 }
Beispiel #10
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
 }
Beispiel #11
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
 }
 /// <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
 }
        /// <summary>Snippet for GetSessionEntityTypeAsync</summary>
        public async Task GetSessionEntityTypeAsync()
        {
            // Snippet: GetSessionEntityTypeAsync(SessionEntityTypeName,CallSettings)
            // Additional: GetSessionEntityTypeAsync(SessionEntityTypeName,CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            SessionEntityTypeName name = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]");
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.GetSessionEntityTypeAsync(name);

            // End snippet
        }
        /// <summary>Snippet for UpdateSessionEntityTypeAsync</summary>
        public async Task UpdateSessionEntityTypeAsync()
        {
            // Snippet: UpdateSessionEntityTypeAsync(SessionEntityType,CallSettings)
            // Additional: UpdateSessionEntityTypeAsync(SessionEntityType,CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            SessionEntityType sessionEntityType = new SessionEntityType();
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.UpdateSessionEntityTypeAsync(sessionEntityType);

            // End snippet
        }
Beispiel #15
0
        /// <summary>Snippet for GetSessionEntityTypeAsync</summary>
        public async Task GetSessionEntityTypeAsync()
        {
            // Snippet: GetSessionEntityTypeAsync(string, CallSettings)
            // Additional: GetSessionEntityTypeAsync(string, CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/sessions/[SESSION]/entityTypes/[ENTITY_TYPE]";
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.GetSessionEntityTypeAsync(name);

            // 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
 }
 /// <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
 }
Beispiel #19
0
        /// <summary>Snippet for CreateSessionEntityTypeAsync</summary>
        public async Task CreateSessionEntityTypeAsync()
        {
            // Snippet: CreateSessionEntityTypeAsync(string, SessionEntityType, CallSettings)
            // Additional: CreateSessionEntityTypeAsync(string, SessionEntityType, CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            string            parent            = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/sessions/[SESSION]";
            SessionEntityType sessionEntityType = new SessionEntityType();
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.CreateSessionEntityTypeAsync(parent, sessionEntityType);

            // End snippet
        }
        /// <summary>Snippet for CreateSessionEntityTypeAsync</summary>
        public async Task CreateSessionEntityTypeAsync()
        {
            // Snippet: CreateSessionEntityTypeAsync(SessionName,SessionEntityType,CallSettings)
            // Additional: CreateSessionEntityTypeAsync(SessionName,SessionEntityType,CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            SessionName       parent            = new SessionName("[PROJECT]", "[SESSION]");
            SessionEntityType sessionEntityType = new SessionEntityType();
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.CreateSessionEntityTypeAsync(parent, sessionEntityType);

            // End snippet
        }
        /// <summary>Snippet for UpdateSessionEntityTypeAsync</summary>
        public async Task UpdateSessionEntityTypeAsync_RequestObject()
        {
            // Snippet: UpdateSessionEntityTypeAsync(UpdateSessionEntityTypeRequest,CallSettings)
            // Additional: UpdateSessionEntityTypeAsync(UpdateSessionEntityTypeRequest,CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            UpdateSessionEntityTypeRequest request = new UpdateSessionEntityTypeRequest
            {
                SessionEntityType = new SessionEntityType(),
            };
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.UpdateSessionEntityTypeAsync(request);

            // End snippet
        }
Beispiel #22
0
        /// <summary>Snippet for GetSessionEntityTypeAsync</summary>
        public async Task GetSessionEntityTypeRequestObjectAsync()
        {
            // Snippet: GetSessionEntityTypeAsync(GetSessionEntityTypeRequest, CallSettings)
            // Additional: GetSessionEntityTypeAsync(GetSessionEntityTypeRequest, CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            GetSessionEntityTypeRequest request = new GetSessionEntityTypeRequest
            {
                SessionEntityTypeName = SessionEntityTypeName.FromProjectLocationAgentSessionEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[SESSION]", "[ENTITY_TYPE]"),
            };
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.GetSessionEntityTypeAsync(request);

            // End snippet
        }
        /// <summary>Snippet for CreateSessionEntityTypeAsync</summary>
        public async Task CreateSessionEntityTypeAsync_RequestObject()
        {
            // Snippet: CreateSessionEntityTypeAsync(CreateSessionEntityTypeRequest,CallSettings)
            // Additional: CreateSessionEntityTypeAsync(CreateSessionEntityTypeRequest,CancellationToken)
            // Create client
            SessionEntityTypesClient sessionEntityTypesClient = await SessionEntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            CreateSessionEntityTypeRequest request = new CreateSessionEntityTypeRequest
            {
                ParentAsSessionName = new SessionName("[PROJECT]", "[SESSION]"),
                SessionEntityType   = new SessionEntityType(),
            };
            // Make the request
            SessionEntityType response = await sessionEntityTypesClient.CreateSessionEntityTypeAsync(request);

            // End snippet
        }
        public async Task UpdateSessionEntityTypeAsync2()
        {
            Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new Mock <SessionEntityTypes.SessionEntityTypesClient>(MockBehavior.Strict);
            UpdateSessionEntityTypeRequest request = new UpdateSessionEntityTypeRequest
            {
                SessionEntityType = new SessionEntityType(),
            };
            SessionEntityType expectedResponse = new SessionEntityType
            {
                SessionEntityTypeName = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
            };

            mockGrpcClient.Setup(x => x.UpdateSessionEntityTypeAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <SessionEntityType>(Task.FromResult(expectedResponse), null, null, null, null));
            SessionEntityTypesClient client   = new SessionEntityTypesClientImpl(mockGrpcClient.Object, null);
            SessionEntityType        response = await client.UpdateSessionEntityTypeAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetSessionEntityType2()
        {
            Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new Mock <SessionEntityTypes.SessionEntityTypesClient>(MockBehavior.Strict);
            GetSessionEntityTypeRequest request = new GetSessionEntityTypeRequest
            {
                SessionEntityTypeName = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
            };
            SessionEntityType expectedResponse = new SessionEntityType
            {
                SessionEntityTypeName = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
            };

            mockGrpcClient.Setup(x => x.GetSessionEntityType(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            SessionEntityTypesClient client   = new SessionEntityTypesClientImpl(mockGrpcClient.Object, null);
            SessionEntityType        response = client.GetSessionEntityType(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void CreateSessionEntityType()
        {
            Mock <SessionEntityTypes.SessionEntityTypesClient> mockGrpcClient = new Mock <SessionEntityTypes.SessionEntityTypesClient>(MockBehavior.Strict);
            CreateSessionEntityTypeRequest expectedRequest = new CreateSessionEntityTypeRequest
            {
                ParentAsSessionName = new SessionName("[PROJECT]", "[SESSION]"),
                SessionEntityType   = new SessionEntityType(),
            };
            SessionEntityType expectedResponse = new SessionEntityType
            {
                SessionEntityTypeName = new SessionEntityTypeName("[PROJECT]", "[SESSION]", "[ENTITY_TYPE]"),
            };

            mockGrpcClient.Setup(x => x.CreateSessionEntityType(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            SessionEntityTypesClient client     = new SessionEntityTypesClientImpl(mockGrpcClient.Object, null);
            SessionName       parent            = new SessionName("[PROJECT]", "[SESSION]");
            SessionEntityType sessionEntityType = new SessionEntityType();
            SessionEntityType response          = client.CreateSessionEntityType(parent, sessionEntityType);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }