SignedInUsersClientImpl.java
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.authorization.implementation;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
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.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.authorization.fluent.SignedInUsersClient;
import com.azure.resourcemanager.authorization.fluent.models.DirectoryObjectInner;
import com.azure.resourcemanager.authorization.fluent.models.UserInner;
import com.azure.resourcemanager.authorization.models.DirectoryObjectListResult;
import com.azure.resourcemanager.authorization.models.GraphErrorException;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in SignedInUsersClient. */
public final class SignedInUsersClientImpl implements SignedInUsersClient {
private final ClientLogger logger = new ClientLogger(SignedInUsersClientImpl.class);
/** The proxy service used to perform REST calls. */
private final SignedInUsersService service;
/** The service client containing this operation class. */
private final GraphRbacManagementClientImpl client;
/**
* Initializes an instance of SignedInUsersClientImpl.
*
* @param client the instance of the service client containing this operation class.
*/
SignedInUsersClientImpl(GraphRbacManagementClientImpl client) {
this.service =
RestProxy.create(SignedInUsersService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for GraphRbacManagementClientSignedInUsers to be used by the proxy
* service to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "GraphRbacManagementC")
private interface SignedInUsersService {
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get("/{tenantID}/me")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(GraphErrorException.class)
Mono<Response<UserInner>> get(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("tenantID") String tenantId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get("/{tenantID}/me/ownedObjects")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(GraphErrorException.class)
Mono<Response<DirectoryObjectListResult>> listOwnedObjects(
@HostParam("$host") String endpoint,
@QueryParam("api-version") String apiVersion,
@PathParam("tenantID") String tenantId,
Context context);
@Headers({"Accept: application/json,text/json", "Content-Type: application/json"})
@Get("/{tenantID}/{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(GraphErrorException.class)
Mono<Response<DirectoryObjectListResult>> listOwnedObjectsNext(
@HostParam("$host") String endpoint,
@PathParam(value = "nextLink", encoded = true) String nextLink,
@QueryParam("api-version") String apiVersion,
@PathParam("tenantID") String tenantId,
Context context);
}
/**
* Gets the details for the currently logged-in user.
*
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details for the currently logged-in user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<UserInner>> getWithResponseAsync() {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getTenantId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getTenantId() is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.get(
this.client.getEndpoint(), this.client.getApiVersion(), this.client.getTenantId(), context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Gets the details for the currently logged-in user.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details for the currently logged-in user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<Response<UserInner>> getWithResponseAsync(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.getTenantId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getTenantId() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getTenantId(), context);
}
/**
* Gets the details for the currently logged-in user.
*
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details for the currently logged-in user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<UserInner> getAsync() {
return getWithResponseAsync()
.flatMap(
(Response<UserInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Gets the details for the currently logged-in user.
*
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details for the currently logged-in user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public UserInner get() {
return getAsync().block();
}
/**
* Gets the details for the currently logged-in user.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the details for the currently logged-in user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<UserInner> getWithResponse(Context context) {
return getWithResponseAsync(context).block();
}
/**
* Get the list of directory objects that are owned by the user.
*
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<DirectoryObjectInner>> listOwnedObjectsSinglePageAsync() {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getTenantId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getTenantId() is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.listOwnedObjects(
this.client.getEndpoint(), this.client.getApiVersion(), this.client.getTenantId(), context))
.<PagedResponse<DirectoryObjectInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().odataNextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the list of directory objects that are owned by the user.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<DirectoryObjectInner>> listOwnedObjectsSinglePageAsync(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.getTenantId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getTenantId() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listOwnedObjects(
this.client.getEndpoint(), this.client.getApiVersion(), this.client.getTenantId(), context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().odataNextLink(),
null));
}
/**
* Get the list of directory objects that are owned by the user.
*
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<DirectoryObjectInner> listOwnedObjectsAsync() {
return new PagedFlux<>(
() -> listOwnedObjectsSinglePageAsync(), nextLink -> listOwnedObjectsNextSinglePageAsync(nextLink));
}
/**
* Get the list of directory objects that are owned by the user.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
private PagedFlux<DirectoryObjectInner> listOwnedObjectsAsync(Context context) {
return new PagedFlux<>(
() -> listOwnedObjectsSinglePageAsync(context),
nextLink -> listOwnedObjectsNextSinglePageAsync(nextLink, context));
}
/**
* Get the list of directory objects that are owned by the user.
*
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DirectoryObjectInner> listOwnedObjects() {
return new PagedIterable<>(listOwnedObjectsAsync());
}
/**
* Get the list of directory objects that are owned by the user.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DirectoryObjectInner> listOwnedObjects(Context context) {
return new PagedIterable<>(listOwnedObjectsAsync(context));
}
/**
* Get the list of directory objects that are owned by the user.
*
* @param nextLink Next link for the list operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<DirectoryObjectInner>> listOwnedObjectsNextSinglePageAsync(String nextLink) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
if (this.client.getTenantId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getTenantId() is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.listOwnedObjectsNext(
this.client.getEndpoint(),
nextLink,
this.client.getApiVersion(),
this.client.getTenantId(),
context))
.<PagedResponse<DirectoryObjectInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().odataNextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the list of directory objects that are owned by the user.
*
* @param nextLink Next link for the list operation.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws GraphErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the list of directory objects that are owned by the user.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
private Mono<PagedResponse<DirectoryObjectInner>> listOwnedObjectsNextSinglePageAsync(
String nextLink, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
if (this.client.getTenantId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getTenantId() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listOwnedObjectsNext(
this.client.getEndpoint(), nextLink, this.client.getApiVersion(), this.client.getTenantId(), context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().odataNextLink(),
null));
}
}