/// <summary>Snippet for CreateProduct</summary>
 public void CreateProductRequestObject()
 {
     // Snippet: CreateProduct(CreateProductRequest, CallSettings)
     // Create client
     ProductServiceClient productServiceClient = ProductServiceClient.Create();
     // Initialize request argument(s)
     CreateProductRequest request = new CreateProductRequest
     {
         ParentAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
         Product            = new Product(),
         ProductId          = "",
     };
     // Make the request
     Product response = productServiceClient.CreateProduct(request);
     // End snippet
 }
        /// <summary>Snippet for CreateProductAsync</summary>
        public async Task CreateProductResourceNamesAsync()
        {
            // Snippet: CreateProductAsync(BranchName, Product, string, CallSettings)
            // Additional: CreateProductAsync(BranchName, Product, string, CancellationToken)
            // Create client
            ProductServiceClient productServiceClient = await ProductServiceClient.CreateAsync();

            // Initialize request argument(s)
            BranchName parent    = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]");
            Product    product   = new Product();
            string     productId = "";
            // Make the request
            Product response = await productServiceClient.CreateProductAsync(parent, product, productId);

            // End snippet
        }
Пример #3
0
        public void CreateProductRequestObject()
        {
            moq::Mock <ProductService.ProductServiceClient> mockGrpcClient = new moq::Mock <ProductService.ProductServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CreateProductRequest request = new CreateProductRequest
            {
                ParentAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Product            = new Product(),
                ProductId          = "product_idde82ea9b",
            };
            Product expectedResponse = new Product
            {
                ProductName      = ProductName.FromProjectLocationCatalogBranchProduct("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]", "[PRODUCT]"),
                Id               = "id74b70bb8",
                Type             = Product.Types.Type.Collection,
                PrimaryProductId = "primary_product_id96202300",
                Categories       =
                {
                    "categoriesb4ccb5b0",
                },
                Title       = "title17dbd3d5",
                Description = "description2cf9da67",
                Attributes  =
                {
                    {
                        "key8a0b6e3c",
                        new CustomAttribute()
                    },
                },
                Tags              = { "tags52c47ad5", },
                PriceInfo         = new PriceInfo(),
                AvailableTime     = new wkt::Timestamp(),
                Availability      = Product.Types.Availability.InStock,
                AvailableQuantity = 719656040,
                Uri    = "uri3db70593",
                Images = { new Image(), },
            };

            mockGrpcClient.Setup(x => x.CreateProduct(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ProductServiceClient client = new ProductServiceClientImpl(mockGrpcClient.Object, null);
            Product response            = client.CreateProduct(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for SetDefaultBranch</summary>
        public void SetDefaultBranchRequestObject()
        {
            // Snippet: SetDefaultBranch(SetDefaultBranchRequest, CallSettings)
            // Create client
            CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
            // Initialize request argument(s)
            SetDefaultBranchRequest request = new SetDefaultBranchRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
                BranchIdAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Note = "",
            };

            // Make the request
            catalogServiceClient.SetDefaultBranch(request);
            // End snippet
        }
        public void SetDefaultBranchRequestObject()
        {
            moq::Mock <CatalogService.CatalogServiceClient> mockGrpcClient = new moq::Mock <CatalogService.CatalogServiceClient>(moq::MockBehavior.Strict);
            SetDefaultBranchRequest request = new SetDefaultBranchRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
                BranchIdAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Note = "noteca53d6aa",
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.SetDefaultBranch(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CatalogServiceClient client = new CatalogServiceClientImpl(mockGrpcClient.Object, null);

            client.SetDefaultBranch(request);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for SetDefaultBranchAsync</summary>
        public async Task SetDefaultBranchRequestObjectAsync()
        {
            // Snippet: SetDefaultBranchAsync(SetDefaultBranchRequest, CallSettings)
            // Additional: SetDefaultBranchAsync(SetDefaultBranchRequest, CancellationToken)
            // Create client
            CatalogServiceClient catalogServiceClient = await CatalogServiceClient.CreateAsync();

            // Initialize request argument(s)
            SetDefaultBranchRequest request = new SetDefaultBranchRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
                BranchIdAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Note = "",
            };
            // Make the request
            await catalogServiceClient.SetDefaultBranchAsync(request);

            // End snippet
        }
        public async stt::Task SetDefaultBranchRequestObjectAsync()
        {
            moq::Mock <CatalogService.CatalogServiceClient> mockGrpcClient = new moq::Mock <CatalogService.CatalogServiceClient>(moq::MockBehavior.Strict);
            SetDefaultBranchRequest request = new SetDefaultBranchRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
                BranchIdAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Note = "noteca53d6aa",
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.SetDefaultBranchAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CatalogServiceClient client = new CatalogServiceClientImpl(mockGrpcClient.Object, null);
            await client.SetDefaultBranchAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.SetDefaultBranchAsync(request, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
        public void GetDefaultBranchResourceNames()
        {
            moq::Mock <CatalogService.CatalogServiceClient> mockGrpcClient = new moq::Mock <CatalogService.CatalogServiceClient>(moq::MockBehavior.Strict);
            GetDefaultBranchRequest request = new GetDefaultBranchRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
            };
            GetDefaultBranchResponse expectedResponse = new GetDefaultBranchResponse
            {
                BranchAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                SetTime            = new wkt::Timestamp(),
                Note = "noteca53d6aa",
            };

            mockGrpcClient.Setup(x => x.GetDefaultBranch(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CatalogServiceClient     client   = new CatalogServiceClientImpl(mockGrpcClient.Object, null);
            GetDefaultBranchResponse response = client.GetDefaultBranch(request.CatalogAsCatalogName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetDefaultBranchResourceNamesAsync()
        {
            moq::Mock <CatalogService.CatalogServiceClient> mockGrpcClient = new moq::Mock <CatalogService.CatalogServiceClient>(moq::MockBehavior.Strict);
            GetDefaultBranchRequest request = new GetDefaultBranchRequest
            {
                CatalogAsCatalogName = CatalogName.FromProjectLocationCatalog("[PROJECT]", "[LOCATION]", "[CATALOG]"),
            };
            GetDefaultBranchResponse expectedResponse = new GetDefaultBranchResponse
            {
                BranchAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                SetTime            = new wkt::Timestamp(),
                Note = "noteca53d6aa",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            GetDefaultBranchResponse responseCancellationToken = await client.GetDefaultBranchAsync(request.CatalogAsCatalogName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for SearchAsync</summary>
        public async Task SearchRequestObjectAsync()
        {
            // Snippet: SearchAsync(SearchRequest, CallSettings)
            // Create client
            SearchServiceClient searchServiceClient = await SearchServiceClient.CreateAsync();

            // Initialize request argument(s)
            SearchRequest request = new SearchRequest
            {
                Placement          = "",
                BranchAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Query      = "",
                VisitorId  = "",
                UserInfo   = new UserInfo(),
                Offset     = 0,
                Filter     = "",
                OrderBy    = "",
                FacetSpecs =
                {
                    new SearchRequest.Types.FacetSpec(),
                },
                BoostSpec          = new SearchRequest.Types.BoostSpec(),
                QueryExpansionSpec = new SearchRequest.Types.QueryExpansionSpec(),
                VariantRollupKeys  = { "", },
                DynamicFacetSpec   = new SearchRequest.Types.DynamicFacetSpec(),
                PageCategories     = { "", },
                CanonicalFilter    = "",
            };
            // Make the request
            PagedAsyncEnumerable <SearchResponse, SearchResponse.Types.SearchResult> response = searchServiceClient.SearchAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((SearchResponse.Types.SearchResult 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((SearchResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (SearchResponse.Types.SearchResult 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 <SearchResponse.Types.SearchResult> 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 (SearchResponse.Types.SearchResult 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
        }