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

com.azure.resourcemanager.billing.implementation.AssociatedTenantsClientImpl Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.billing.implementation;

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.Delete;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Put;
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.management.exception.ManagementException;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.polling.PollerFlux;
import com.azure.core.util.polling.SyncPoller;
import com.azure.resourcemanager.billing.fluent.AssociatedTenantsClient;
import com.azure.resourcemanager.billing.fluent.models.AssociatedTenantInner;
import com.azure.resourcemanager.billing.models.AssociatedTenantListResult;
import java.nio.ByteBuffer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

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

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

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

    /**
     * The interface defining all the services for BillingManagementClientAssociatedTenants to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{$host}")
    @ServiceInterface(name = "BillingManagementCli")
    public interface AssociatedTenantsService {
        @Headers({ "Content-Type: application/json" })
        @Delete("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}")
        @ExpectedResponses({ 202, 204 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> delete(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("associatedTenantName") String associatedTenantName,
            @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> get(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("associatedTenantName") String associatedTenantName,
            @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Put("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants/{associatedTenantName}")
        @ExpectedResponses({ 200, 201 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono>> createOrUpdate(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @PathParam("associatedTenantName") String associatedTenantName,
            @QueryParam("api-version") String apiVersion,
            @BodyParam("application/json") AssociatedTenantInner parameters, @HeaderParam("Accept") String accept,
            Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/associatedTenants")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByBillingAccount(@HostParam("$host") String endpoint,
            @PathParam("billingAccountName") String billingAccountName,
            @QueryParam("includeRevoked") Boolean includeRevoked, @QueryParam("api-version") String apiVersion,
            @QueryParam("filter") String filter, @QueryParam("orderBy") String orderBy, @QueryParam("top") Long top,
            @QueryParam("skip") Long skip, @QueryParam("count") Boolean count, @QueryParam("search") String search,
            @HeaderParam("Accept") String accept, Context context);

        @Headers({ "Content-Type: application/json" })
        @Get("{nextLink}")
        @ExpectedResponses({ 200 })
        @UnexpectedResponseExceptionType(ManagementException.class)
        Mono> listByBillingAccountNext(
            @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("$host") String endpoint,
            @HeaderParam("Accept") String accept, Context context);
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> deleteWithResponseAsync(String billingAccountName,
        String associatedTenantName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (associatedTenantName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associatedTenantName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.delete(this.client.getEndpoint(), billingAccountName, associatedTenantName,
                this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> deleteWithResponseAsync(String billingAccountName,
        String associatedTenantName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (associatedTenantName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associatedTenantName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.delete(this.client.getEndpoint(), billingAccountName, associatedTenantName,
            this.client.getApiVersion(), accept, context);
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, Void> beginDeleteAsync(String billingAccountName,
        String associatedTenantName) {
        Mono>> mono = deleteWithResponseAsync(billingAccountName, associatedTenantName);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            this.client.getContext());
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, Void> beginDeleteAsync(String billingAccountName, String associatedTenantName,
        Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = deleteWithResponseAsync(billingAccountName, associatedTenantName, context);
        return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class,
            context);
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, Void> beginDelete(String billingAccountName, String associatedTenantName) {
        return this.beginDeleteAsync(billingAccountName, associatedTenantName).getSyncPoller();
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of long-running operation.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, Void> beginDelete(String billingAccountName, String associatedTenantName,
        Context context) {
        return this.beginDeleteAsync(billingAccountName, associatedTenantName, context).getSyncPoller();
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono deleteAsync(String billingAccountName, String associatedTenantName) {
        return beginDeleteAsync(billingAccountName, associatedTenantName).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono deleteAsync(String billingAccountName, String associatedTenantName, Context context) {
        return beginDeleteAsync(billingAccountName, associatedTenantName, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String billingAccountName, String associatedTenantName) {
        deleteAsync(billingAccountName, associatedTenantName).block();
    }

    /**
     * Deletes an associated tenant for a billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void delete(String billingAccountName, String associatedTenantName, Context context) {
        deleteAsync(billingAccountName, associatedTenantName, context).block();
    }

    /**
     * Gets an associated tenant by ID.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant by ID along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String billingAccountName,
        String associatedTenantName) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (associatedTenantName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associatedTenantName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.get(this.client.getEndpoint(), billingAccountName, associatedTenantName,
                this.client.getApiVersion(), accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Gets an associated tenant by ID.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant by ID along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> getWithResponseAsync(String billingAccountName,
        String associatedTenantName, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (associatedTenantName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associatedTenantName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.get(this.client.getEndpoint(), billingAccountName, associatedTenantName,
            this.client.getApiVersion(), accept, context);
    }

    /**
     * Gets an associated tenant by ID.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant by ID on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono getAsync(String billingAccountName, String associatedTenantName) {
        return getWithResponseAsync(billingAccountName, associatedTenantName)
            .flatMap(res -> Mono.justOrEmpty(res.getValue()));
    }

    /**
     * Gets an associated tenant by ID.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant by ID along with {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response getWithResponse(String billingAccountName, String associatedTenantName,
        Context context) {
        return getWithResponseAsync(billingAccountName, associatedTenantName, context).block();
    }

    /**
     * Gets an associated tenant by ID.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant by ID.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociatedTenantInner get(String billingAccountName, String associatedTenantName) {
        return getWithResponse(billingAccountName, associatedTenantName, Context.NONE).getValue();
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateWithResponseAsync(String billingAccountName,
        String associatedTenantName, AssociatedTenantInner parameters) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (associatedTenantName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associatedTenantName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), billingAccountName,
                associatedTenantName, this.client.getApiVersion(), parameters, accept, context))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant along with {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono>> createOrUpdateWithResponseAsync(String billingAccountName,
        String associatedTenantName, AssociatedTenantInner parameters, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        if (associatedTenantName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter associatedTenantName is required and cannot be null."));
        }
        if (parameters == null) {
            return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null."));
        } else {
            parameters.validate();
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.createOrUpdate(this.client.getEndpoint(), billingAccountName, associatedTenantName,
            this.client.getApiVersion(), parameters, accept, context);
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of an associated tenant.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, AssociatedTenantInner> beginCreateOrUpdateAsync(
        String billingAccountName, String associatedTenantName, AssociatedTenantInner parameters) {
        Mono>> mono
            = createOrUpdateWithResponseAsync(billingAccountName, associatedTenantName, parameters);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), AssociatedTenantInner.class, AssociatedTenantInner.class,
            this.client.getContext());
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link PollerFlux} for polling of an associated tenant.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    private PollerFlux, AssociatedTenantInner> beginCreateOrUpdateAsync(
        String billingAccountName, String associatedTenantName, AssociatedTenantInner parameters, Context context) {
        context = this.client.mergeContext(context);
        Mono>> mono
            = createOrUpdateWithResponseAsync(billingAccountName, associatedTenantName, parameters, context);
        return this.client.getLroResult(mono,
            this.client.getHttpPipeline(), AssociatedTenantInner.class, AssociatedTenantInner.class, context);
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of an associated tenant.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, AssociatedTenantInner>
        beginCreateOrUpdate(String billingAccountName, String associatedTenantName, AssociatedTenantInner parameters) {
        return this.beginCreateOrUpdateAsync(billingAccountName, associatedTenantName, parameters).getSyncPoller();
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link SyncPoller} for polling of an associated tenant.
     */
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller, AssociatedTenantInner> beginCreateOrUpdate(
        String billingAccountName, String associatedTenantName, AssociatedTenantInner parameters, Context context) {
        return this.beginCreateOrUpdateAsync(billingAccountName, associatedTenantName, parameters, context)
            .getSyncPoller();
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateAsync(String billingAccountName, String associatedTenantName,
        AssociatedTenantInner parameters) {
        return beginCreateOrUpdateAsync(billingAccountName, associatedTenantName, parameters).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono createOrUpdateAsync(String billingAccountName, String associatedTenantName,
        AssociatedTenantInner parameters, Context context) {
        return beginCreateOrUpdateAsync(billingAccountName, associatedTenantName, parameters, context).last()
            .flatMap(this.client::getLroFinalResultOrError);
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociatedTenantInner createOrUpdate(String billingAccountName, String associatedTenantName,
        AssociatedTenantInner parameters) {
        return createOrUpdateAsync(billingAccountName, associatedTenantName, parameters).block();
    }

    /**
     * Create or update an associated tenant for the billing account.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param associatedTenantName The ID that uniquely identifies a tenant.
     * @param parameters An associated tenant.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return an associated tenant.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public AssociatedTenantInner createOrUpdate(String billingAccountName, String associatedTenantName,
        AssociatedTenantInner parameters, Context context) {
        return createOrUpdateAsync(billingAccountName, associatedTenantName, parameters, context).block();
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param includeRevoked Can be used to get revoked associated tenants.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param top The top query option requests the number of items in the queried collection to be included in the
     * result. The maximum supported value for top is 50.
     * @param skip The skip query option requests the number of items in the queried collection that are to be skipped
     * and not included in the result.
     * @param count The count query option allows clients to request a count of the matching resources included with the
     * resources in the response.
     * @param search The search query option allows clients to request items within a collection matching a free-text
     * search expression. search is only supported for string fields.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountSinglePageAsync(String billingAccountName,
        Boolean includeRevoked, String filter, String orderBy, Long top, Long skip, Boolean count, String search) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listByBillingAccount(this.client.getEndpoint(), billingAccountName, includeRevoked,
                    this.client.getApiVersion(), filter, orderBy, top, skip, count, search, accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param includeRevoked Can be used to get revoked associated tenants.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param top The top query option requests the number of items in the queried collection to be included in the
     * result. The maximum supported value for top is 50.
     * @param skip The skip query option requests the number of items in the queried collection that are to be skipped
     * and not included in the result.
     * @param count The count query option allows clients to request a count of the matching resources included with the
     * resources in the response.
     * @param search The search query option allows clients to request items within a collection matching a free-text
     * search expression. search is only supported for string fields.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountSinglePageAsync(String billingAccountName,
        Boolean includeRevoked, String filter, String orderBy, Long top, Long skip, Boolean count, String search,
        Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (billingAccountName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter billingAccountName is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service
            .listByBillingAccount(this.client.getEndpoint(), billingAccountName, includeRevoked,
                this.client.getApiVersion(), filter, orderBy, top, skip, count, search, accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param includeRevoked Can be used to get revoked associated tenants.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param top The top query option requests the number of items in the queried collection to be included in the
     * result. The maximum supported value for top is 50.
     * @param skip The skip query option requests the number of items in the queried collection that are to be skipped
     * and not included in the result.
     * @param count The count query option allows clients to request a count of the matching resources included with the
     * resources in the response.
     * @param search The search query option allows clients to request items within a collection matching a free-text
     * search expression. search is only supported for string fields.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName,
        Boolean includeRevoked, String filter, String orderBy, Long top, Long skip, Boolean count, String search) {
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, includeRevoked, filter,
            orderBy, top, skip, count, search), nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName) {
        final Boolean includeRevoked = null;
        final String filter = null;
        final String orderBy = null;
        final Long top = null;
        final Long skip = null;
        final Boolean count = null;
        final String search = null;
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, includeRevoked, filter,
            orderBy, top, skip, count, search), nextLink -> listByBillingAccountNextSinglePageAsync(nextLink));
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param includeRevoked Can be used to get revoked associated tenants.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param top The top query option requests the number of items in the queried collection to be included in the
     * result. The maximum supported value for top is 50.
     * @param skip The skip query option requests the number of items in the queried collection that are to be skipped
     * and not included in the result.
     * @param count The count query option allows clients to request a count of the matching resources included with the
     * resources in the response.
     * @param search The search query option allows clients to request items within a collection matching a free-text
     * search expression. search is only supported for string fields.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources as paginated response with {@link PagedFlux}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    private PagedFlux listByBillingAccountAsync(String billingAccountName,
        Boolean includeRevoked, String filter, String orderBy, Long top, Long skip, Boolean count, String search,
        Context context) {
        return new PagedFlux<>(() -> listByBillingAccountSinglePageAsync(billingAccountName, includeRevoked, filter,
            orderBy, top, skip, count, search, context),
            nextLink -> listByBillingAccountNextSinglePageAsync(nextLink, context));
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingAccount(String billingAccountName) {
        final Boolean includeRevoked = null;
        final String filter = null;
        final String orderBy = null;
        final Long top = null;
        final Long skip = null;
        final Boolean count = null;
        final String search = null;
        return new PagedIterable<>(
            listByBillingAccountAsync(billingAccountName, includeRevoked, filter, orderBy, top, skip, count, search));
    }

    /**
     * Lists the associated tenants that can collaborate with the billing account on commerce activities like viewing
     * and downloading invoices, managing payments, making purchases, and managing or provisioning licenses.
     * 
     * @param billingAccountName The ID that uniquely identifies a billing account.
     * @param includeRevoked Can be used to get revoked associated tenants.
     * @param filter The filter query option allows clients to filter a collection of resources that are addressed by a
     * request URL.
     * @param orderBy The orderby query option allows clients to request resources in a particular order.
     * @param top The top query option requests the number of items in the queried collection to be included in the
     * result. The maximum supported value for top is 50.
     * @param skip The skip query option requests the number of items in the queried collection that are to be skipped
     * and not included in the result.
     * @param count The count query option allows clients to request a count of the matching resources included with the
     * resources in the response.
     * @param search The search query option allows clients to request items within a collection matching a free-text
     * search expression. search is only supported for string fields.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources as paginated response with {@link PagedIterable}.
     */
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable listByBillingAccount(String billingAccountName, Boolean includeRevoked,
        String filter, String orderBy, Long top, Long skip, Boolean count, String search, Context context) {
        return new PagedIterable<>(listByBillingAccountAsync(billingAccountName, includeRevoked, filter, orderBy, top,
            skip, count, search, context));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountNextSinglePageAsync(String nextLink) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        return FluxUtil
            .withContext(
                context -> service.listByBillingAccountNext(nextLink, this.client.getEndpoint(), accept, context))
            .>map(res -> new PagedResponseBase<>(res.getRequest(),
                res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null))
            .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
    }

    /**
     * Get the next page of items.
     * 
     * @param nextLink The URL to get the next list of items.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ManagementException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return a container for a list of resources along with {@link PagedResponse} on successful completion of
     * {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    private Mono> listByBillingAccountNextSinglePageAsync(String nextLink,
        Context context) {
        if (nextLink == null) {
            return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
        }
        if (this.client.getEndpoint() == null) {
            return Mono.error(
                new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        final String accept = "application/json";
        context = this.client.mergeContext(context);
        return service.listByBillingAccountNext(nextLink, this.client.getEndpoint(), accept, context)
            .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
                res.getValue().value(), res.getValue().nextLink(), null));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy