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

com.azure.communication.rooms.implementation.ParticipantsImpl Maven / Gradle / Ivy

Go to download

This package contains clients and data structures used to create, update, get, delete the Azure Communication Room Service. For this release, see notes Microsoft Azure Communication Rooms quickstart

There is a newer version: 1.1.5
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.communication.rooms.implementation;

import com.azure.communication.rooms.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.rooms.implementation.models.ParticipantsCollection;
import com.azure.communication.rooms.implementation.models.RoomParticipant;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Patch;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in Participants. */
public final class ParticipantsImpl {
    /** The proxy service used to perform REST calls. */
    private final ParticipantsService service;

    /** The service client containing this operation class. */
    private final AzureCommunicationRoomServiceImpl client;

    /**
     * Initializes an instance of ParticipantsImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    ParticipantsImpl(AzureCommunicationRoomServiceImpl client) {
        this.service =
                RestProxy.create(ParticipantsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for AzureCommunicationRoomServiceParticipants to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "AzureCommunicationRo")
    public interface ParticipantsService {
        @Get("/rooms/{roomId}/participants")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono> list(
                @HostParam("endpoint") String endpoint,
                @PathParam("roomId") String roomId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("/rooms/{roomId}/participants")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Response listSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("roomId") String roomId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Patch("/rooms/{roomId}/participants")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono> update(
                @HostParam("endpoint") String endpoint,
                @PathParam("roomId") String roomId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/merge-patch+json") String updateParticipantsRequest,
                @HeaderParam("Accept") String accept,
                Context context);

        @Patch("/rooms/{roomId}/participants")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Response updateSync(
                @HostParam("endpoint") String endpoint,
                @PathParam("roomId") String roomId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/merge-patch+json") String updateParticipantsRequest,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono> listNext(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                Context context);

        @Get("{nextLink}")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Response listNextSync(
                @PathParam(value = "nextLink", encoded = true) String nextLink,
                @HostParam("endpoint") String endpoint,
                @HeaderParam("Accept") String accept,
                Context context);
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono> listSinglePageAsync(String roomId) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                        context ->
                                service.list(
                                        this.client.getEndpoint(),
                                        roomId,
                                        this.client.getApiVersion(),
                                        accept,
                                        context))
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room along with {@link PagedResponse} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono> listSinglePageAsync(String roomId, Context context) {
        final String accept = "application/json";
        return service.list(this.client.getEndpoint(), roomId, this.client.getApiVersion(), accept, context)
                .map(
                        res ->
                                new PagedResponseBase<>(
                                        res.getRequest(),
                                        res.getStatusCode(),
                                        res.getHeaders(),
                                        res.getValue().getValue(),
                                        res.getValue().getNextLink(),
                                        null));
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux listAsync(String roomId) {
        return new PagedFlux<>(() -> listSinglePageAsync(roomId), nextLink -> listNextSinglePageAsync(nextLink));
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedFlux listAsync(String roomId, Context context) {
        return new PagedFlux<>(
                () -> listSinglePageAsync(roomId, context), nextLink -> listNextSinglePageAsync(nextLink, context));
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse listSinglePage(String roomId) {
        final String accept = "application/json";
        Response res =
                service.listSync(this.client.getEndpoint(), roomId, this.client.getApiVersion(), accept, Context.NONE);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                res.getValue().getValue(),
                res.getValue().getNextLink(),
                null);
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room along with {@link PagedResponse}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public PagedResponse listSinglePage(String roomId, Context context) {
        final String accept = "application/json";
        Response res =
                service.listSync(this.client.getEndpoint(), roomId, this.client.getApiVersion(), accept, context);
        return new PagedResponseBase<>(
                res.getRequest(),
                res.getStatusCode(),
                res.getHeaders(),
                res.getValue().getValue(),
                res.getValue().getNextLink(),
                null);
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list(String roomId) {
        return new PagedIterable<>(
                () -> listSinglePage(roomId, Context.NONE), nextLink -> listNextSinglePage(nextLink));
    }

    /**
     * Get participants in a room.
     *
     * @param roomId The id of the room to get participants from.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return participants in a room as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable list(String roomId, Context context) {
        return new PagedIterable<>(
                () -> listSinglePage(roomId, context), nextLink -> listNextSinglePage(nextLink, context));
    }

    /**
     * Update participants in a room.
     *
     * @param roomId The id of the room to update the participants in.
     * @param updateParticipantsRequest An updated set of participants of the room.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return any object along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono> updateWithResponseAsync(String roomId, String updateParticipantsRequest) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.update(
                                this.client.getEndpoint(),
                                roomId,
                                this.client.getApiVersion(),
                                updateParticipantsRequest,
                                accept,
                                context));
    }

    /**
     * Update participants in a room.
     *
     * @param roomId The id of the room to update the participants in.
     * @param updateParticipantsRequest An updated set of participants of the room.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return any object along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono> updateWithResponseAsync(
            String roomId, String updateParticipantsRequest, Context context) {
        final String accept = "application/json";
        return service.update(
                this.client.getEndpoint(),
                roomId,
                this.client.getApiVersion(),
                updateParticipantsRequest,
                accept,
                context);
    }

    /**
     * Update participants in a room.
     *
     * @param roomId The id of the room to update the participants in.
     * @param updateParticipantsRequest An updated set of participants of the room.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return any object on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono updateAsync(String roomId, String updateParticipantsRequest) {
        return updateWithResponseAsync(roomId, updateParticipantsRequest)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Update participants in a room.
     *
     * @param roomId The id of the room to update the participants in.
     * @param updateParticipantsRequest An updated set of participants of the room.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return any object on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono updateAsync(String roomId, String updateParticipantsRequest, Context context) {
        return updateWithResponseAsync(roomId, updateParticipantsRequest, context)
                .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Update participants in a room.
     *
     * @param roomId The id of the room to update the participants in.
     * @param updateParticipantsRequest An updated set of participants of the room.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return any object along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response updateWithResponse(String roomId, String updateParticipantsRequest, Context context) {
        final String accept = "application/json";
        return service.updateSync(
                this.client.getEndpoint(),
                roomId,
                this.client.getApiVersion(),
                updateParticipantsRequest,
                accept,
                context);
    }

    /**
     * Update participants in a room.
     *
     * @param roomId The id of the room to update the participants in.
     * @param updateParticipantsRequest An updated set of participants of the room.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return any object.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Object update(String roomId, String updateParticipantsRequest) {
        return updateWithResponse(roomId, updateParticipantsRequest, Context.NONE).getValue();
    }

    /**
     * Get the next page of items.
     *
     * @param nextLink The URL to get the next list of items
     *     

The nextLink parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws CommunicationErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return a collection of participants in a room along with {@link PagedResponse} on successful completion of * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> listNextSinglePageAsync(String nextLink) { final String accept = "application/json"; return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) .map( res -> new PagedResponseBase<>( res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().getValue(), res.getValue().getNextLink(), null)); } /** * Get the next page of items. * * @param nextLink The URL to get the next list of items *

The nextLink parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws CommunicationErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return a collection of participants in a room along with {@link PagedResponse} on successful completion of * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> listNextSinglePageAsync(String nextLink, Context context) { final String accept = "application/json"; return service.listNext(nextLink, this.client.getEndpoint(), accept, context) .map( res -> new PagedResponseBase<>( res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().getValue(), res.getValue().getNextLink(), null)); } /** * Get the next page of items. * * @param nextLink The URL to get the next list of items *

The nextLink parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws CommunicationErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return a collection of participants in a room along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) public PagedResponse listNextSinglePage(String nextLink) { final String accept = "application/json"; Response res = service.listNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); return new PagedResponseBase<>( res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().getValue(), res.getValue().getNextLink(), null); } /** * Get the next page of items. * * @param nextLink The URL to get the next list of items *

The nextLink parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws CommunicationErrorResponseException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return a collection of participants in a room along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) public PagedResponse listNextSinglePage(String nextLink, Context context) { final String accept = "application/json"; Response res = service.listNextSync(nextLink, this.client.getEndpoint(), accept, context); return new PagedResponseBase<>( res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().getValue(), res.getValue().getNextLink(), null); } }