com.azure.resourcemanager.hybridcompute.implementation.ExtensionMetadatasClientImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-hybridcompute Show documentation
Show all versions of azure-resourcemanager-hybridcompute Show documentation
This package contains Microsoft Azure SDK for HybridCompute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Hybrid Compute Management Client. Package tag package-preview-2024-05.
The 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.resourcemanager.hybridcompute.implementation;
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.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.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.resourcemanager.hybridcompute.fluent.ExtensionMetadatasClient;
import com.azure.resourcemanager.hybridcompute.fluent.models.ExtensionValueInner;
import com.azure.resourcemanager.hybridcompute.models.ExtensionValueListResult;
import reactor.core.publisher.Mono;
/**
* An instance of this class provides access to all the operations defined in ExtensionMetadatasClient.
*/
public final class ExtensionMetadatasClientImpl implements ExtensionMetadatasClient {
/**
* The proxy service used to perform REST calls.
*/
private final ExtensionMetadatasService service;
/**
* The service client containing this operation class.
*/
private final HybridComputeManagementClientImpl client;
/**
* Initializes an instance of ExtensionMetadatasClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
ExtensionMetadatasClientImpl(HybridComputeManagementClientImpl client) {
this.service = RestProxy.create(ExtensionMetadatasService.class, client.getHttpPipeline(),
client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for HybridComputeManagementClientExtensionMetadatas to be used by the
* proxy service to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "HybridComputeManagem")
public interface ExtensionMetadatasService {
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions/{version}")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> get(@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
@PathParam("location") String location, @PathParam("publisher") String publisher,
@PathParam("extensionType") String extensionType, @PathParam("version") String version,
@HeaderParam("Accept") String accept, Context context);
@Headers({ "Content-Type: application/json" })
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/locations/{location}/publishers/{publisher}/extensionTypes/{extensionType}/versions")
@ExpectedResponses({ 200 })
@UnexpectedResponseExceptionType(ManagementException.class)
Mono> list(@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId,
@PathParam("location") String location, @PathParam("publisher") String publisher,
@PathParam("extensionType") String extensionType, @HeaderParam("Accept") String accept, Context context);
}
/**
* Gets an Extension Metadata based on location, publisher, extensionType and version.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @param version The version of the Extension being received.
* @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 Extension Metadata based on location, publisher, extensionType and version along with {@link Response}
* on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String location, String publisher,
String extensionType, String version) {
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 (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (publisher == null) {
return Mono.error(new IllegalArgumentException("Parameter publisher is required and cannot be null."));
}
if (extensionType == null) {
return Mono.error(new IllegalArgumentException("Parameter extensionType is required and cannot be null."));
}
if (version == null) {
return Mono.error(new IllegalArgumentException("Parameter version is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), location, publisher, extensionType, version, accept, context))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Gets an Extension Metadata based on location, publisher, extensionType and version.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @param version The version of the Extension being received.
* @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 Extension Metadata based on location, publisher, extensionType and version along with {@link Response}
* on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> getWithResponseAsync(String location, String publisher,
String extensionType, String version, 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 (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (publisher == null) {
return Mono.error(new IllegalArgumentException("Parameter publisher is required and cannot be null."));
}
if (extensionType == null) {
return Mono.error(new IllegalArgumentException("Parameter extensionType is required and cannot be null."));
}
if (version == null) {
return Mono.error(new IllegalArgumentException("Parameter version is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(),
location, publisher, extensionType, version, accept, context);
}
/**
* Gets an Extension Metadata based on location, publisher, extensionType and version.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @param version The version of the Extension being received.
* @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 Extension Metadata based on location, publisher, extensionType and version on successful completion of
* {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono getAsync(String location, String publisher, String extensionType,
String version) {
return getWithResponseAsync(location, publisher, extensionType, version)
.flatMap(res -> Mono.justOrEmpty(res.getValue()));
}
/**
* Gets an Extension Metadata based on location, publisher, extensionType and version.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @param version The version of the Extension being received.
* @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 Extension Metadata based on location, publisher, extensionType and version along with
* {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response getWithResponse(String location, String publisher, String extensionType,
String version, Context context) {
return getWithResponseAsync(location, publisher, extensionType, version, context).block();
}
/**
* Gets an Extension Metadata based on location, publisher, extensionType and version.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @param version The version of the Extension being received.
* @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 Extension Metadata based on location, publisher, extensionType and version.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ExtensionValueInner get(String location, String publisher, String extensionType, String version) {
return getWithResponse(location, publisher, extensionType, version, Context.NONE).getValue();
}
/**
* Gets all Extension versions based on location, publisher, extensionType.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @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 all Extension versions based on location, publisher, extensionType along with {@link PagedResponse} on
* successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listSinglePageAsync(String location, String publisher,
String extensionType) {
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 (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (publisher == null) {
return Mono.error(new IllegalArgumentException("Parameter publisher is required and cannot be null."));
}
if (extensionType == null) {
return Mono.error(new IllegalArgumentException("Parameter extensionType is required and cannot be null."));
}
final String accept = "application/json";
return FluxUtil
.withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(),
this.client.getSubscriptionId(), location, publisher, extensionType, accept, context))
.>map(res -> new PagedResponseBase<>(res.getRequest(),
res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null))
.contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly()));
}
/**
* Gets all Extension versions based on location, publisher, extensionType.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @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 all Extension versions based on location, publisher, extensionType along with {@link PagedResponse} on
* successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono> listSinglePageAsync(String location, String publisher,
String extensionType, 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 (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (publisher == null) {
return Mono.error(new IllegalArgumentException("Parameter publisher is required and cannot be null."));
}
if (extensionType == null) {
return Mono.error(new IllegalArgumentException("Parameter extensionType is required and cannot be null."));
}
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), location,
publisher, extensionType, accept, context)
.map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
res.getValue().value(), null, null));
}
/**
* Gets all Extension versions based on location, publisher, extensionType.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @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 all Extension versions based on location, publisher, extensionType as paginated response with
* {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync(String location, String publisher, String extensionType) {
return new PagedFlux<>(() -> listSinglePageAsync(location, publisher, extensionType));
}
/**
* Gets all Extension versions based on location, publisher, extensionType.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @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 all Extension versions based on location, publisher, extensionType as paginated response with
* {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux listAsync(String location, String publisher, String extensionType,
Context context) {
return new PagedFlux<>(() -> listSinglePageAsync(location, publisher, extensionType, context));
}
/**
* Gets all Extension versions based on location, publisher, extensionType.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @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 all Extension versions based on location, publisher, extensionType as paginated response with
* {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable list(String location, String publisher, String extensionType) {
return new PagedIterable<>(listAsync(location, publisher, extensionType));
}
/**
* Gets all Extension versions based on location, publisher, extensionType.
*
* @param location The location of the Extension being received.
* @param publisher The publisher of the Extension being received.
* @param extensionType The extensionType of the Extension being received.
* @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 all Extension versions based on location, publisher, extensionType as paginated response with
* {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable list(String location, String publisher, String extensionType,
Context context) {
return new PagedIterable<>(listAsync(location, publisher, extensionType, context));
}
}