com.azure.resourcemanager.videoanalyzer.implementation.LocationsClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-videoanalyzer Show documentation
Show all versions of azure-resourcemanager-videoanalyzer Show documentation
We’re retiring the Azure Video Analyzer preview service; you're advised to transition your applications off of Video Analyzer by 01 December 2022. This SDK is no longer maintained and won’t work after the service is retired. To learn how to transition off, please refer to: https://aka.ms/azsdk/videoanalyzer/transitionoffguidance This package contains Microsoft Azure SDK for Video Analyzer Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Video Analyzer provides a platform for you to build intelligent video applications that span the edge and the cloud. Package tag package-preview-2021-11.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.videoanalyzer.implementation;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
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.Post;
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.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.videoanalyzer.fluent.LocationsClient;
import com.azure.resourcemanager.videoanalyzer.fluent.models.CheckNameAvailabilityResponseInner;
import com.azure.resourcemanager.videoanalyzer.models.CheckNameAvailabilityRequest;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in LocationsClient. */
public final class LocationsClientImpl implements LocationsClient {
private final ClientLogger logger = new ClientLogger(LocationsClientImpl.class);
/** The proxy service used to perform REST calls. */
private final LocationsService service;
/** The service client containing this operation class. */
private final VideoAnalyzerManagementClientImpl client;
/**
* Initializes an instance of LocationsClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
LocationsClientImpl(VideoAnalyzerManagementClientImpl client) {
this.service =
RestProxy.create(LocationsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for VideoAnalyzerManagementClientLocations to be used by the proxy
* service to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "VideoAnalyzerManagem")
private interface LocationsService {
@Headers({"Content-Type: application/json"})
@Post(
"/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> checkNameAvailability(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@PathParam("locationName") String locationName,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") CheckNameAvailabilityRequest parameters,
@HeaderParam("Accept") String accept,
Context context);
}
/**
* Checks whether the Video Analyzer resource name is available.
*
* @param locationName The name of the location.
* @param parameters The request parameters.
* @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 check availability result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> checkNameAvailabilityWithResponseAsync(
String locationName, CheckNameAvailabilityRequest parameters) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (locationName == null) {
return Mono.error(new IllegalArgumentException("Parameter locationName 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
.checkNameAvailability(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
locationName,
this.client.getApiVersion(),
parameters,
accept,
context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Checks whether the Video Analyzer resource name is available.
*
* @param locationName The name of the location.
* @param parameters The request parameters.
* @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 check availability result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> checkNameAvailabilityWithResponseAsync(
String locationName, CheckNameAvailabilityRequest parameters, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
if (locationName == null) {
return Mono.error(new IllegalArgumentException("Parameter locationName 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
.checkNameAvailability(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
locationName,
this.client.getApiVersion(),
parameters,
accept,
context);
}
/**
* Checks whether the Video Analyzer resource name is available.
*
* @param locationName The name of the location.
* @param parameters The request parameters.
* @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 check availability result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono checkNameAvailabilityAsync(
String locationName, CheckNameAvailabilityRequest parameters) {
return checkNameAvailabilityWithResponseAsync(locationName, parameters)
.flatMap(
(Response res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Checks whether the Video Analyzer resource name is available.
*
* @param locationName The name of the location.
* @param parameters The request parameters.
* @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 check availability result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public CheckNameAvailabilityResponseInner checkNameAvailability(
String locationName, CheckNameAvailabilityRequest parameters) {
return checkNameAvailabilityAsync(locationName, parameters).block();
}
/**
* Checks whether the Video Analyzer resource name is available.
*
* @param locationName The name of the location.
* @param parameters The request parameters.
* @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 check availability result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response checkNameAvailabilityWithResponse(
String locationName, CheckNameAvailabilityRequest parameters, Context context) {
return checkNameAvailabilityWithResponseAsync(locationName, parameters, context).block();
}
}