コード例 #1
0
        /// <summary>Snippet for ImportUserEventsAsync</summary>
        public async Task ImportUserEventsResourceNamesAsync()
        {
            // Snippet: ImportUserEventsAsync(EventStoreName, string, InputConfig, ImportErrorsConfig, CallSettings)
            // Additional: ImportUserEventsAsync(EventStoreName, string, InputConfig, ImportErrorsConfig, CancellationToken)
            // Create client
            UserEventServiceClient userEventServiceClient = await UserEventServiceClient.CreateAsync();

            // Initialize request argument(s)
            EventStoreName     parent       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
            string             requestId    = "";
            InputConfig        inputConfig  = new InputConfig();
            ImportErrorsConfig errorsConfig = new ImportErrorsConfig();
            // Make the request
            Operation <ImportUserEventsResponse, ImportMetadata> response = await userEventServiceClient.ImportUserEventsAsync(parent, requestId, inputConfig, errorsConfig);

            // Poll until the returned long-running operation is complete
            Operation <ImportUserEventsResponse, ImportMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            ImportUserEventsResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <ImportUserEventsResponse, ImportMetadata> retrievedResponse = await userEventServiceClient.PollOnceImportUserEventsAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ImportUserEventsResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
コード例 #2
0
        /// <summary>Snippet for ImportUserEvents</summary>
        public void ImportUserEventsRequestObject()
        {
            // Snippet: ImportUserEvents(ImportUserEventsRequest, CallSettings)
            // Create client
            UserEventServiceClient userEventServiceClient = UserEventServiceClient.Create();
            // Initialize request argument(s)
            ImportUserEventsRequest request = new ImportUserEventsRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                RequestId    = "",
                InputConfig  = new InputConfig(),
                ErrorsConfig = new ImportErrorsConfig(),
            };
            // Make the request
            Operation <ImportUserEventsResponse, ImportMetadata> response = userEventServiceClient.ImportUserEvents(request);

            // Poll until the returned long-running operation is complete
            Operation <ImportUserEventsResponse, ImportMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            ImportUserEventsResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <ImportUserEventsResponse, ImportMetadata> retrievedResponse = userEventServiceClient.PollOnceImportUserEvents(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ImportUserEventsResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
コード例 #3
0
        public void CollectUserEventRequestObject()
        {
            moq::Mock <UserEventService.UserEventServiceClient> mockGrpcClient = new moq::Mock <UserEventService.UserEventServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CollectUserEventRequest request = new CollectUserEventRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                UserEvent = "user_eventc8146d99",
                Uri       = "uri3db70593",
                Ets       = -4649673071663131288L,
            };
            ga::HttpBody expectedResponse = new ga::HttpBody
            {
                ContentType = "content_type085be0ea",
                Data        = proto::ByteString.CopyFromUtf8("data387f778d"),
                Extensions  = { new wkt::Any(), },
            };

            mockGrpcClient.Setup(x => x.CollectUserEvent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            UserEventServiceClient client   = new UserEventServiceClientImpl(mockGrpcClient.Object, null);
            ga::HttpBody           response = client.CollectUserEvent(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #4
0
        public async stt::Task CollectUserEventResourceNamesAsync()
        {
            moq::Mock <UserEventService.UserEventServiceClient> mockGrpcClient = new moq::Mock <UserEventService.UserEventServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CollectUserEventRequest request = new CollectUserEventRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                UserEvent = "user_eventc8146d99",
                Uri       = "uri3db70593",
                Ets       = -4649673071663131288L,
            };
            ga::HttpBody expectedResponse = new ga::HttpBody
            {
                ContentType = "content_type085be0ea",
                Data        = proto::ByteString.CopyFromUtf8("data387f778d"),
                Extensions  = { new wkt::Any(), },
            };

            mockGrpcClient.Setup(x => x.CollectUserEventAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ga::HttpBody>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            UserEventServiceClient client = new UserEventServiceClientImpl(mockGrpcClient.Object, null);
            ga::HttpBody           responseCallSettings = await client.CollectUserEventAsync(request.ParentAsEventStoreName, request.UserEvent, request.Uri, request.Ets, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ga::HttpBody responseCancellationToken = await client.CollectUserEventAsync(request.ParentAsEventStoreName, request.UserEvent, request.Uri, request.Ets, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #5
0
        public async stt::Task WriteUserEventRequestObjectAsync()
        {
            moq::Mock <UserEventService.UserEventServiceClient> mockGrpcClient = new moq::Mock <UserEventService.UserEventServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            WriteUserEventRequest request = new WriteUserEventRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                UserEvent = new UserEvent(),
            };
            UserEvent expectedResponse = new UserEvent
            {
                EventType          = "event_type1436d01c",
                UserInfo           = new UserInfo(),
                EventDetail        = new EventDetail(),
                ProductEventDetail = new ProductEventDetail(),
                EventTime          = new wkt::Timestamp(),
                EventSource        = UserEvent.Types.EventSource.Automl,
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #6
0
        /// <summary>Snippet for PurgeUserEventsAsync</summary>
        public async Task PurgeUserEventsResourceNamesAsync()
        {
            // Snippet: PurgeUserEventsAsync(EventStoreName, string, bool, CallSettings)
            // Additional: PurgeUserEventsAsync(EventStoreName, string, bool, CancellationToken)
            // Create client
            UserEventServiceClient userEventServiceClient = await UserEventServiceClient.CreateAsync();

            // Initialize request argument(s)
            EventStoreName parent = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
            string         filter = "";
            bool           force  = false;
            // Make the request
            Operation <PurgeUserEventsResponse, PurgeUserEventsMetadata> response = await userEventServiceClient.PurgeUserEventsAsync(parent, filter, force);

            // Poll until the returned long-running operation is complete
            Operation <PurgeUserEventsResponse, PurgeUserEventsMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            PurgeUserEventsResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <PurgeUserEventsResponse, PurgeUserEventsMetadata> retrievedResponse = await userEventServiceClient.PollOncePurgeUserEventsAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                PurgeUserEventsResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
コード例 #7
0
        public void WriteUserEvent()
        {
            moq::Mock <UserEventService.UserEventServiceClient> mockGrpcClient = new moq::Mock <UserEventService.UserEventServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            WriteUserEventRequest request = new WriteUserEventRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                UserEvent = new UserEvent(),
            };
            UserEvent expectedResponse = new UserEvent
            {
                EventType          = "event_type1436d01c",
                UserInfo           = new UserInfo(),
                EventDetail        = new EventDetail(),
                ProductEventDetail = new ProductEventDetail(),
                EventTime          = new wkt::Timestamp(),
                EventSource        = UserEvent.Types.EventSource.Automl,
            };

            mockGrpcClient.Setup(x => x.WriteUserEvent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            UserEventServiceClient client = new UserEventServiceClientImpl(mockGrpcClient.Object, null);
            UserEvent response            = client.WriteUserEvent(request.Parent, request.UserEvent);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #8
0
 /// <summary>Snippet for CreatePredictionApiKeyRegistration</summary>
 public void CreatePredictionApiKeyRegistrationResourceNames()
 {
     // Snippet: CreatePredictionApiKeyRegistration(EventStoreName, PredictionApiKeyRegistration, CallSettings)
     // Create client
     PredictionApiKeyRegistryClient predictionApiKeyRegistryClient = PredictionApiKeyRegistryClient.Create();
     // Initialize request argument(s)
     EventStoreName parent = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
     PredictionApiKeyRegistration predictionApiKeyRegistration = new PredictionApiKeyRegistration();
     // Make the request
     PredictionApiKeyRegistration response = predictionApiKeyRegistryClient.CreatePredictionApiKeyRegistration(parent, predictionApiKeyRegistration);
     // End snippet
 }
コード例 #9
0
 /// <summary>Snippet for WriteUserEvent</summary>
 public void WriteUserEventResourceNames()
 {
     // Snippet: WriteUserEvent(EventStoreName, UserEvent, CallSettings)
     // Create client
     UserEventServiceClient userEventServiceClient = UserEventServiceClient.Create();
     // Initialize request argument(s)
     EventStoreName parent    = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
     UserEvent      userEvent = new UserEvent();
     // Make the request
     UserEvent response = userEventServiceClient.WriteUserEvent(parent, userEvent);
     // End snippet
 }
コード例 #10
0
 /// <summary>Snippet for CollectUserEvent</summary>
 public void CollectUserEventResourceNames()
 {
     // Snippet: CollectUserEvent(EventStoreName, string, string, long, CallSettings)
     // Create client
     UserEventServiceClient userEventServiceClient = UserEventServiceClient.Create();
     // Initialize request argument(s)
     EventStoreName parent    = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
     string         userEvent = "";
     string         uri       = "";
     long           ets       = 0L;
     // Make the request
     HttpBody response = userEventServiceClient.CollectUserEvent(parent, userEvent, uri, ets);
     // End snippet
 }
コード例 #11
0
        /// <summary>Snippet for ListUserEvents</summary>
        public async Task ListUserEventsRequestObjectAsync()
        {
            // Snippet: ListUserEventsAsync(ListUserEventsRequest, CallSettings)
            // Create client
            UserEventServiceClient userEventServiceClient = await UserEventServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListUserEventsRequest request = new ListUserEventsRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                Filter = "",
            };
            // Make the request
            PagedAsyncEnumerable <ListUserEventsResponse, UserEvent> response = userEventServiceClient.ListUserEventsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((UserEvent item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListUserEventsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (UserEvent 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 <UserEvent> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (UserEvent 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
        }
コード例 #12
0
        /// <summary>Snippet for CreatePredictionApiKeyRegistrationAsync</summary>
        public async Task CreatePredictionApiKeyRegistrationResourceNamesAsync()
        {
            // Snippet: CreatePredictionApiKeyRegistrationAsync(EventStoreName, PredictionApiKeyRegistration, CallSettings)
            // Additional: CreatePredictionApiKeyRegistrationAsync(EventStoreName, PredictionApiKeyRegistration, CancellationToken)
            // Create client
            PredictionApiKeyRegistryClient predictionApiKeyRegistryClient = await PredictionApiKeyRegistryClient.CreateAsync();

            // Initialize request argument(s)
            EventStoreName parent = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
            PredictionApiKeyRegistration predictionApiKeyRegistration = new PredictionApiKeyRegistration();
            // Make the request
            PredictionApiKeyRegistration response = await predictionApiKeyRegistryClient.CreatePredictionApiKeyRegistrationAsync(parent, predictionApiKeyRegistration);

            // End snippet
        }
コード例 #13
0
 /// <summary>Snippet for CreatePredictionApiKeyRegistration</summary>
 public void CreatePredictionApiKeyRegistrationRequestObject()
 {
     // Snippet: CreatePredictionApiKeyRegistration(CreatePredictionApiKeyRegistrationRequest, CallSettings)
     // Create client
     PredictionApiKeyRegistryClient predictionApiKeyRegistryClient = PredictionApiKeyRegistryClient.Create();
     // Initialize request argument(s)
     CreatePredictionApiKeyRegistrationRequest request = new CreatePredictionApiKeyRegistrationRequest
     {
         ParentAsEventStoreName       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
         PredictionApiKeyRegistration = new PredictionApiKeyRegistration(),
     };
     // Make the request
     PredictionApiKeyRegistration response = predictionApiKeyRegistryClient.CreatePredictionApiKeyRegistration(request);
     // End snippet
 }
コード例 #14
0
 /// <summary>Snippet for WriteUserEvent</summary>
 public void WriteUserEventRequestObject()
 {
     // Snippet: WriteUserEvent(WriteUserEventRequest, CallSettings)
     // Create client
     UserEventServiceClient userEventServiceClient = UserEventServiceClient.Create();
     // Initialize request argument(s)
     WriteUserEventRequest request = new WriteUserEventRequest
     {
         ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
         UserEvent = new UserEvent(),
     };
     // Make the request
     UserEvent response = userEventServiceClient.WriteUserEvent(request);
     // End snippet
 }
コード例 #15
0
        /// <summary>Snippet for WriteUserEventAsync</summary>
        public async Task WriteUserEventResourceNamesAsync()
        {
            // Snippet: WriteUserEventAsync(EventStoreName, UserEvent, CallSettings)
            // Additional: WriteUserEventAsync(EventStoreName, UserEvent, CancellationToken)
            // Create client
            UserEventServiceClient userEventServiceClient = await UserEventServiceClient.CreateAsync();

            // Initialize request argument(s)
            EventStoreName parent    = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
            UserEvent      userEvent = new UserEvent();
            // Make the request
            UserEvent response = await userEventServiceClient.WriteUserEventAsync(parent, userEvent);

            // End snippet
        }
コード例 #16
0
        /// <summary>Snippet for ListPredictionApiKeyRegistrations</summary>
        public void ListPredictionApiKeyRegistrationsRequestObject()
        {
            // Snippet: ListPredictionApiKeyRegistrations(ListPredictionApiKeyRegistrationsRequest, CallSettings)
            // Create client
            PredictionApiKeyRegistryClient predictionApiKeyRegistryClient = PredictionApiKeyRegistryClient.Create();
            // Initialize request argument(s)
            ListPredictionApiKeyRegistrationsRequest request = new ListPredictionApiKeyRegistrationsRequest
            {
                ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
            };
            // Make the request
            PagedEnumerable <ListPredictionApiKeyRegistrationsResponse, PredictionApiKeyRegistration> response = predictionApiKeyRegistryClient.ListPredictionApiKeyRegistrations(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (PredictionApiKeyRegistration 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 (ListPredictionApiKeyRegistrationsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (PredictionApiKeyRegistration 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 <PredictionApiKeyRegistration> 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 (PredictionApiKeyRegistration 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
        }
コード例 #17
0
 /// <summary>Snippet for CollectUserEvent</summary>
 public void CollectUserEventRequestObject()
 {
     // Snippet: CollectUserEvent(CollectUserEventRequest, CallSettings)
     // Create client
     UserEventServiceClient userEventServiceClient = UserEventServiceClient.Create();
     // Initialize request argument(s)
     CollectUserEventRequest request = new CollectUserEventRequest
     {
         ParentAsEventStoreName = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
         UserEvent = "",
         Uri       = "",
         Ets       = 0L,
     };
     // Make the request
     HttpBody response = userEventServiceClient.CollectUserEvent(request);
     // End snippet
 }
コード例 #18
0
        /// <summary>Snippet for ListPredictionApiKeyRegistrationsAsync</summary>
        public async Task ListPredictionApiKeyRegistrationsResourceNamesAsync()
        {
            // Snippet: ListPredictionApiKeyRegistrationsAsync(EventStoreName, string, int?, CallSettings)
            // Create client
            PredictionApiKeyRegistryClient predictionApiKeyRegistryClient = await PredictionApiKeyRegistryClient.CreateAsync();

            // Initialize request argument(s)
            EventStoreName parent = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
            // Make the request
            PagedAsyncEnumerable <ListPredictionApiKeyRegistrationsResponse, PredictionApiKeyRegistration> response = predictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((PredictionApiKeyRegistration item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListPredictionApiKeyRegistrationsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (PredictionApiKeyRegistration 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 <PredictionApiKeyRegistration> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (PredictionApiKeyRegistration 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
        }
コード例 #19
0
        /// <summary>Snippet for ListUserEvents</summary>
        public void ListUserEventsResourceNames()
        {
            // Snippet: ListUserEvents(EventStoreName, string, string, int?, CallSettings)
            // Create client
            UserEventServiceClient userEventServiceClient = UserEventServiceClient.Create();
            // Initialize request argument(s)
            EventStoreName parent = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
            string         filter = "";
            // Make the request
            PagedEnumerable <ListUserEventsResponse, UserEvent> response = userEventServiceClient.ListUserEvents(parent, filter);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (UserEvent 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 (ListUserEventsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (UserEvent 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 <UserEvent> 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 (UserEvent 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
        }
        public void CreatePredictionApiKeyRegistration()
        {
            moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient> mockGrpcClient = new moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient>(moq::MockBehavior.Strict);
            CreatePredictionApiKeyRegistrationRequest request = new CreatePredictionApiKeyRegistrationRequest
            {
                ParentAsEventStoreName       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                PredictionApiKeyRegistration = new PredictionApiKeyRegistration(),
            };
            PredictionApiKeyRegistration expectedResponse = new PredictionApiKeyRegistration
            {
                ApiKey = "api_key30288039",
            };

            mockGrpcClient.Setup(x => x.CreatePredictionApiKeyRegistration(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            PredictionApiKeyRegistryClient client   = new PredictionApiKeyRegistryClientImpl(mockGrpcClient.Object, null);
            PredictionApiKeyRegistration   response = client.CreatePredictionApiKeyRegistration(request.Parent, request.PredictionApiKeyRegistration);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreatePredictionApiKeyRegistrationAsync()
        {
            moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient> mockGrpcClient = new moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient>(moq::MockBehavior.Strict);
            CreatePredictionApiKeyRegistrationRequest request = new CreatePredictionApiKeyRegistrationRequest
            {
                ParentAsEventStoreName       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                PredictionApiKeyRegistration = new PredictionApiKeyRegistration(),
            };
            PredictionApiKeyRegistration expectedResponse = new PredictionApiKeyRegistration
            {
                ApiKey = "api_key30288039",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            PredictionApiKeyRegistration responseCancellationToken = await client.CreatePredictionApiKeyRegistrationAsync(request.Parent, request.PredictionApiKeyRegistration, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #22
0
 /// <summary>
 /// Register an API key for use with predict method.
 /// </summary>
 /// <param name="parent">
 /// Required. The parent resource path.
 /// "projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store".
 /// </param>
 /// <param name="predictionApiKeyRegistration">
 /// Required. The prediction API key registration.
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <PredictionApiKeyRegistration> CreatePredictionApiKeyRegistrationAsync(EventStoreName parent, PredictionApiKeyRegistration predictionApiKeyRegistration, gaxgrpc::CallSettings callSettings = null) =>
 CreatePredictionApiKeyRegistrationAsync(new CreatePredictionApiKeyRegistrationRequest
 {
     ParentAsEventStoreName       = gax::GaxPreconditions.CheckNotNull(parent, nameof(parent)),
     PredictionApiKeyRegistration = gax::GaxPreconditions.CheckNotNull(predictionApiKeyRegistration, nameof(predictionApiKeyRegistration)),
 }, callSettings);
コード例 #23
0
 /// <summary>
 /// Register an API key for use with predict method.
 /// </summary>
 /// <param name="parent">
 /// Required. The parent resource path.
 /// "projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store".
 /// </param>
 /// <param name="predictionApiKeyRegistration">
 /// Required. The prediction API key registration.
 /// </param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <PredictionApiKeyRegistration> CreatePredictionApiKeyRegistrationAsync(EventStoreName parent, PredictionApiKeyRegistration predictionApiKeyRegistration, st::CancellationToken cancellationToken) =>
 CreatePredictionApiKeyRegistrationAsync(parent, predictionApiKeyRegistration, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
コード例 #24
0
 /// <summary>
 /// List the registered apiKeys for use with predict method.
 /// </summary>
 /// <param name="parent">
 /// Required. The parent placement resource name such as
 /// "projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store"
 /// </param>
 /// <param name="pageToken">
 /// The token returned from the previous request. A value of <c>null</c> or an empty string retrieves the first
 /// page.
 /// </param>
 /// <param name="pageSize">
 /// The size of page to request. The response will not be larger than this, but may be smaller. A value of
 /// <c>null</c> or <c>0</c> uses a server-defined page size.
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A pageable asynchronous sequence of <see cref="PredictionApiKeyRegistration"/> resources.</returns>
 public virtual gax::PagedAsyncEnumerable <ListPredictionApiKeyRegistrationsResponse, PredictionApiKeyRegistration> ListPredictionApiKeyRegistrationsAsync(EventStoreName parent, string pageToken = null, int?pageSize = null, gaxgrpc::CallSettings callSettings = null) =>
 ListPredictionApiKeyRegistrationsAsync(new ListPredictionApiKeyRegistrationsRequest
 {
     ParentAsEventStoreName = gax::GaxPreconditions.CheckNotNull(parent, nameof(parent)),
     PageToken = pageToken ?? "",
     PageSize  = pageSize ?? 0,
 }, callSettings);