// [END vision_product_search_create_product] // [START vision_product_search_list_products] private static int ListProducts(ListProductsOptions opts) { var client = ProductSearchClient.Create(); var request = new ListProductsRequest { // A resource that represents Google Cloud Platform location. ParentAsLocationName = new LocationName(opts.ProjectID, opts.ComputeRegion) }; var products = client.ListProducts(request); foreach (var product in products) { var productId = product.Name.Split("/").Last(); Console.WriteLine($"\nProduct name: {product.Name}"); Console.WriteLine($"Product id: {productId}"); Console.WriteLine($"Product display name: {product.DisplayName}"); Console.WriteLine($"Product category: {product.ProductCategory}"); Console.WriteLine($"Product labels:"); foreach (var label in product.ProductLabels) { Console.WriteLine($"\tLabel: {label.ToString()}"); } } return(0); }
private static void listProducts(RabbitmqClient client) { var req = new ListProductsRequest { Engine = ListProductsRequest.EngineEnum.RABBITMQ, }; try { var resp = client.ListProducts(req); Console.WriteLine(resp.GetHttpBody()); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }
private static void queryProducts(IoTDAClient client) { ListProductsRequest req = new ListProductsRequest { InstanceId = "1a7ffc5c-d89c-44dd-8265-b1653d951ce0" }; try { var resp = client.ListProducts(req); Console.WriteLine(resp.HttpStatusCode); Console.WriteLine(resp.Page); foreach (var Product in resp.Products) { Console.WriteLine(JsonConvert.SerializeObject(Product)); } } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }
public async Task ListProducts_Valid_OK() { var listRequest = new ListProductsRequest { }; var actual = await Fixture.Api.Products.ListProductsAsync(listRequest); Assert.Equal(HttpStatusCode.OK, actual.StatusCode); var actualContent = actual.Data; Assert.Equal(2, actualContent.Records.Count); var expectedFirst = _productRecords[0]; var actualFirst = actualContent.Records[0]; Assert.True(actualFirst.Id > 0); Assert.Equal($"{expectedFirst.ProductCode} - {expectedFirst.ProductName}", actualFirst.Name); var expectedSecond = _productRecords[1]; var actualSecond = actualContent.Records[1]; Assert.True(actualSecond.Id > 0); Assert.Equal($"{expectedSecond.ProductCode} - {expectedSecond.ProductName}", actualSecond.Name); }
public override Task <ListProductsResponse> ListProducts(ListProductsRequest request, ServerCallContext context) { var response = new ListProductsResponse(); response.Products.Add(_products); return(Task.FromResult(response)); }
public async Task <ActionResult <ListProductsResponse> > ListProductsAsync() { var request = new ListProductsRequest { }; var response = await Service.ListProductsAsync(request); return(Ok(response)); }
/// <summary> /// 查询产品规格列表 /// </summary> public async Task <ListProductsResponse> ListProductsAsync(ListProductsRequest listProductsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v2/products", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", listProductsRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ListProductsResponse>(response)); }
/// <summary> /// 查询产品规格列表 /// </summary> public ListProductsResponse ListProducts(ListProductsRequest listProductsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v2/products", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, listProductsRequest); HttpResponseMessage response = DoHttpRequestSync("GET", request); return(JsonUtils.DeSerialize <ListProductsResponse>(response)); }
public async Task HandleAsync_ValidRequest_ReturnsResponse() { var products = new List <Product> { new Product(new ProductIdentity(1), "ABC", "My name", 12), new Product(new ProductIdentity(2), "BDE", "My name 2", 14), }; _repositoryMock.Setup(e => e.GetAsync()).Returns(Task.FromResult(products.AsEnumerable())); var request = new ListProductsRequest(); await _useCase.HandleAsync(request); _mapperMock.Verify(e => e.Map <IEnumerable <Product>, ListProductsResponse>(products), Times.Once); }
/// <summary>Snippet for ListProductsAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task ListProductsRequestObjectAsync() { // Create client CloudChannelServiceClient cloudChannelServiceClient = await CloudChannelServiceClient.CreateAsync(); // Initialize request argument(s) ListProductsRequest request = new ListProductsRequest { Account = "", LanguageCode = "", }; // Make the request PagedAsyncEnumerable <ListProductsResponse, Product> response = cloudChannelServiceClient.ListProductsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Product 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((ListProductsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Product 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 <Product> 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 (Product 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; }
public async Task ListProducts_ValidRequest_ReturnsResponse() { var request = new ListProductsRequest { }; var response = await Fixture.Products.ListProductsAsync(request); Assert.Equal(_productRecords.Count, response.Count); for (int i = 0; i < _productRecords.Count; i++) { var expected = _productRecords[i]; var actual = response.Records[i]; Assert.Equal(expected.Id, actual.Id); Assert.Equal($"{expected.ProductCode} - {expected.ProductName}", actual.Name); } Assert.NotNull(response); }
protected override void ProcessRecord() { base.ProcessRecord(); ListProductsRequest request; try { request = new ListProductsRequest { TenancyId = TenancyId, SubscriptionId = SubscriptionId, UsagePeriodKey = UsagePeriodKey, OpcRequestId = OpcRequestId, Page = Page, Limit = Limit, SortOrder = SortOrder, SortBy = SortBy, Producttype = Producttype }; IEnumerable <ListProductsResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.ProductCollection, true); } if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null) { WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources."); } FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// 查看产品列表接口 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public ListProductsResponse ListProducts(ListProductsRequest request) { return(new ListProductsExecutor().Client(this).Execute <ListProductsResponse, ListProductsResult, ListProductsRequest>(request)); }
public Task <ListProductsResponse> ListProductsAsync(ListProductsRequest request) { return(HandleAsync <ListProductsRequest, ListProductsResponse>(request)); }
public IHttpActionResult ListActive(ListProductsRequest request) { return(Ok(new { a = User.Identity.IsAuthenticated, sales = _saleService.GetAllActive(User.Identity.IsAuthenticated ? User.Identity.GetUserId() : string.Empty) })); }
public Task <IObjectClientResponse <ListProductsResponse> > ListProductsAsync(ListProductsRequest request) { return(Client.GetAsync <ListProductsResponse>("list")); }
public Task <ListProductsResponse> ListProductsAsync(ListProductsRequest request) { return(ExecuteAsync(e => e.ListProductsAsync(request))); }
/// <summary> /// 查看产品列表接口 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <ListProductsResponse> ListProducts(ListProductsRequest request) { return(await new ListProductsExecutor().Client(this).Execute <ListProductsResponse, ListProductsResult, ListProductsRequest>(request).ConfigureAwait(false)); }