All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.communication.messages.MessageTemplateAsyncClient Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.
package com.azure.communication.messages;

import com.azure.communication.messages.implementation.MessageTemplateClientImpl;
import com.azure.communication.messages.models.MessageTemplateItem;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.util.BinaryData;
import java.util.stream.Collectors;
import reactor.core.publisher.Flux;

/**
 * Initializes a new instance of the asynchronous MessageTemplateClient type.
 */
@ServiceClient(builder = MessageTemplateClientBuilder.class, isAsync = true)
public final class MessageTemplateAsyncClient {

    @Generated
    private final MessageTemplateClientImpl serviceClient;

    /**
     * Initializes an instance of MessageTemplateAsyncClient class.
     *
     * @param serviceClient the service client implementation.
     */
    @Generated
    MessageTemplateAsyncClient(MessageTemplateClientImpl serviceClient) {
        this.serviceClient = serviceClient;
    }

    /**
     * List all templates for given Azure Communication Services channel.
     * 

Query Parameters

* * * * *
Query Parameters
NameTypeRequiredDescription
maxpagesizeIntegerNoNumber of objects to return per page.
* You can add these to a request with {@link RequestOptions#addQueryParam} *

Response Body Schema

* *
     * {@code
     * {
     *     kind: String(whatsApp) (Required)
     *     name: String (Required)
     *     language: String (Required)
     *     status: String(approved/rejected/pending/paused) (Required)
     * }
     * }
     * 
* * @param channelId The registration ID of the channel. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @return paged collection of MessageTemplateItem items as paginated response with {@link PagedFlux}. */ @Generated @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listTemplates(String channelId, RequestOptions requestOptions) { return this.serviceClient.listTemplatesAsync(channelId, requestOptions); } /** * List all templates for given Azure Communication Services channel. * * @param channelId The registration ID of the channel. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return paged collection of MessageTemplateItem items as paginated response with {@link PagedFlux}. */ @Generated @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listTemplates(String channelId) { // Generated convenience method for listTemplates RequestOptions requestOptions = new RequestOptions(); PagedFlux pagedFluxResponse = listTemplates(channelId, requestOptions); return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { Flux> flux = (continuationTokenParam == null) ? pagedFluxResponse.byPage().take(1) : pagedFluxResponse.byPage(continuationTokenParam).take(1); return flux .map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), pagedResponse.getStatusCode(), pagedResponse.getHeaders(), pagedResponse.getValue() .stream() .map(protocolMethodData -> protocolMethodData.toObject(MessageTemplateItem.class)) .collect(Collectors.toList()), pagedResponse.getContinuationToken(), null)); }); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy