/// <summary>Snippet for ListApplications</summary> public async Task ListApplicationsRequestObjectAsync() { // Snippet: ListApplicationsAsync(ListApplicationsRequest, CallSettings) // Create client ApplicationServiceClient applicationServiceClient = await ApplicationServiceClient.CreateAsync(); // Initialize request argument(s) ListApplicationsRequest request = new ListApplicationsRequest { ParentAsProfileName = ProfileName.FromProjectTenantProfile("[PROJECT]", "[TENANT]", "[PROFILE]"), }; // Make the request PagedAsyncEnumerable <ListApplicationsResponse, Application> response = applicationServiceClient.ListApplicationsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Application 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((ListApplicationsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Application 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 <Application> 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 (Application 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 }
/// <summary> /// Creates a new enumerable which will iterate over the ApplicationSummary objects /// contained in responses from the ListApplications operation. This enumerable will fetch more data from the server as needed. /// </summary> /// <param name="request">The request object containing the details to send</param> /// <param name="retryConfiguration">The configuration for retrying, may be null</param> /// <param name="cancellationToken">The cancellation token object</param> /// <returns>The enumerator, which supports a simple iteration over a collection of a specified type</returns> public IEnumerable <ApplicationSummary> ListApplicationsRecordEnumerator(ListApplicationsRequest request, Common.Retry.RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { return(new Common.Utils.ResponseRecordEnumerable <ListApplicationsRequest, ListApplicationsResponse, ApplicationSummary>( response => response.OpcNextPage, input => { if (!string.IsNullOrEmpty(input)) { request.Page = input; } return request; }, request => client.ListApplications(request, retryConfiguration, cancellationToken), response => response.ApplicationCollection.Items )); }
/// <summary> /// 获取应用列表信息。 /// </summary> /// <param name="req"><see cref="ListApplicationsRequest"/></param> /// <returns><see cref="ListApplicationsResponse"/></returns> public async Task <ListApplicationsResponse> ListApplications(ListApplicationsRequest req) { JsonResponseModel <ListApplicationsResponse> rsp = null; try { var strResp = await this.InternalRequest(req, "ListApplications"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <ListApplicationsResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
/** * Gets the Application info of a single uniquely named Application in the specified compartment. * * @param fnManagementClient the service client to use to get the Application information. * @param compartmentId of the application. * @param applicationDisplayName of the application. * @return the ApplicationSummary. */ private static async Task <ApplicationSummary> GetUniqueApplicationByName(FunctionsManagementClient fnManagementClient, string compartmentId) { var listApplicationRequest = new ListApplicationsRequest { DisplayName = AppName, CompartmentId = compartmentId }; var listApplicationResponse = await fnManagementClient.ListApplications(listApplicationRequest); if (listApplicationResponse.Items.Count != 1) { logger.Error($"Could not find unique application with name: {AppName} in compartment: {compartmentId}"); return(null); } return(listApplicationResponse.Items[0]); }
protected override void ProcessRecord() { base.ProcessRecord(); ListApplicationsRequest request; try { request = new ListApplicationsRequest { CompartmentId = CompartmentId, ServiceCatalogId = ServiceCatalogId, EntityType = EntityType, OpcRequestId = OpcRequestId, Limit = Limit, Page = Page, DisplayName = DisplayName, EntityId = EntityId, PublisherId = PublisherId, PackageType = PackageType, Pricing = Pricing, IsFeatured = IsFeatured, SortOrder = SortOrder }; IEnumerable <ListApplicationsResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.ApplicationCollection, 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); } }
protected override void ProcessRecord() { base.ProcessRecord(); ListApplicationsRequest request; try { request = new ListApplicationsRequest { WorkspaceId = WorkspaceId, Name = Name, NameContains = NameContains, Identifier = Identifier, Fields = Fields, Limit = Limit, Page = Page, SortOrder = SortOrder, SortBy = SortBy, OpcRequestId = OpcRequestId }; IEnumerable <ListApplicationsResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.ApplicationSummaryCollection, 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); } }
protected override void ProcessRecord() { base.ProcessRecord(); ListApplicationsRequest request; try { request = new ListApplicationsRequest { CompartmentId = CompartmentId, OpcRequestId = OpcRequestId, Limit = Limit, Page = Page, SortBy = SortBy, SortOrder = SortOrder, DisplayName = DisplayName, OwnerPrincipalId = OwnerPrincipalId, DisplayNameStartsWith = DisplayNameStartsWith, SparkVersion = SparkVersion }; IEnumerable <ListApplicationsResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.Items, 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); } }
public void ListApplications(bool passCreds, bool passParameters) { var expectedResult = @"{ ""page_size"": 10, ""page"": 1, ""total_items"": 6, ""total_pages"": 1, ""_embedded"": { ""applications"": [ { ""id"": ""78d335fa323d01149c3dd6f0d48968cf"", ""name"": ""My Application"", ""capabilities"": { ""voice"": { ""webhooks"": { ""answer_url"": { ""address"": ""https://example.com/webhooks/answer"", ""http_method"": ""GET"" }, ""fallback_answer_url"": { ""address"": ""https://fallback.example.com/webhooks/answer"", ""http_method"": ""GET"" }, ""event_url"": { ""address"": ""https://example.com/webhooks/event"", ""http_method"": ""POST"" } } }, ""messages"": { ""webhooks"": { ""inbound_url"": { ""address"": ""https://example.com/webhooks/inbound"", ""http_method"": ""POST"" }, ""status_url"": { ""address"": ""https://example.com/webhooks/status"", ""http_method"": ""POST"" } } }, ""rtc"": { ""webhooks"": { ""event_url"": { ""address"": ""https://example.com/webhooks/event"", ""http_method"": ""POST"" } } }, ""vbc"": {} } } ] } }"; string expectedUri; ListApplicationsRequest request; if (passParameters) { expectedUri = $"{ApiUrl}/v2/applications?page_size=10&page=1&"; request = new ListApplicationsRequest { Page = 1, PageSize = 10 }; } else { expectedUri = $"{ApiUrl}/v2/applications"; request = new ListApplicationsRequest(); } Setup(expectedUri, expectedResult); //Act var creds = Request.Credentials.FromApiKeyAndSecret(ApiKey, ApiSecret); var client = new VonageClient(creds); ApplicationPage applications; if (passCreds) { applications = client.ApplicationClient.ListApplications(request, creds); } else { applications = client.ApplicationClient.ListApplications(request); } Application application = applications.Embedded.Applications[0]; Assert.Equal("78d335fa323d01149c3dd6f0d48968cf", application.Id); Assert.Equal("https://example.com/webhooks/answer", application.Capabilities.Voice.Webhooks[Common.Webhook.Type.answer_url].Address); Assert.Equal("GET", application.Capabilities.Voice.Webhooks[Common.Webhook.Type.answer_url].Method); Assert.Equal("https://fallback.example.com/webhooks/answer", application.Capabilities.Voice.Webhooks[Common.Webhook.Type.fallback_answer_url].Address); Assert.Equal("GET", application.Capabilities.Voice.Webhooks[Common.Webhook.Type.fallback_answer_url].Method); Assert.Equal("https://example.com/webhooks/event", application.Capabilities.Voice.Webhooks[Common.Webhook.Type.event_url].Address); Assert.Equal("POST", application.Capabilities.Voice.Webhooks[Common.Webhook.Type.event_url].Method); Assert.Equal("https://example.com/webhooks/inbound", application.Capabilities.Messages.Webhooks[Common.Webhook.Type.inbound_url].Address); Assert.Equal("POST", application.Capabilities.Messages.Webhooks[Common.Webhook.Type.inbound_url].Method); Assert.Equal("https://example.com/webhooks/status", application.Capabilities.Messages.Webhooks[Common.Webhook.Type.status_url].Address); Assert.Equal("POST", application.Capabilities.Messages.Webhooks[Common.Webhook.Type.status_url].Method); Assert.Equal("https://example.com/webhooks/event", application.Capabilities.Rtc.Webhooks[Common.Webhook.Type.event_url].Address); Assert.Equal("POST", application.Capabilities.Rtc.Webhooks[Common.Webhook.Type.event_url].Method); Assert.Equal("My Application", application.Name); Assert.Equal(6, applications.TotalItems); Assert.Equal(1, applications.TotalPages); Assert.Equal(10, applications.PageSize); Assert.Equal(1, applications.Page); }