WorkspaceGitRepoManagementsImpl.java
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.analytics.synapse.artifacts.implementation;
import com.azure.analytics.synapse.artifacts.models.GitHubAccessTokenRequest;
import com.azure.analytics.synapse.artifacts.models.GitHubAccessTokenResponse;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
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.exception.HttpResponseException;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in WorkspaceGitRepoManagements. */
public final class WorkspaceGitRepoManagementsImpl {
/** The proxy service used to perform REST calls. */
private final WorkspaceGitRepoManagementsService service;
/** The service client containing this operation class. */
private final ArtifactsClientImpl client;
/**
* Initializes an instance of WorkspaceGitRepoManagementsImpl.
*
* @param client the instance of the service client containing this operation class.
*/
WorkspaceGitRepoManagementsImpl(ArtifactsClientImpl client) {
this.service =
RestProxy.create(
WorkspaceGitRepoManagementsService.class,
client.getHttpPipeline(),
client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for ArtifactsClientWorkspaceGitRepoManagements to be used by the proxy
* service to perform REST calls.
*/
@Host("{endpoint}")
@ServiceInterface(name = "ArtifactsClientWorks")
private interface WorkspaceGitRepoManagementsService {
@Post("/getGitHubAccessToken")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<Response<GitHubAccessTokenResponse>> getGitHubAccessToken(
@HostParam("endpoint") String endpoint,
@HeaderParam("x-ms-client-request-id") String clientRequestId,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") GitHubAccessTokenRequest gitHubAccessTokenRequest,
@HeaderParam("Accept") String accept,
Context context);
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @param clientRequestId Can provide a guid, which is helpful for debugging and to provide better customer support.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<GitHubAccessTokenResponse>> getGitHubAccessTokenWithResponseAsync(
GitHubAccessTokenRequest gitHubAccessTokenRequest, String clientRequestId) {
final String apiVersion = "2020-12-01";
final String accept = "application/json";
return FluxUtil.withContext(
context ->
service.getGitHubAccessToken(
this.client.getEndpoint(),
clientRequestId,
apiVersion,
gitHubAccessTokenRequest,
accept,
context));
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @param clientRequestId Can provide a guid, which is helpful for debugging and to provide better customer support.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<GitHubAccessTokenResponse>> getGitHubAccessTokenWithResponseAsync(
GitHubAccessTokenRequest gitHubAccessTokenRequest, String clientRequestId, Context context) {
final String apiVersion = "2020-12-01";
final String accept = "application/json";
return service.getGitHubAccessToken(
this.client.getEndpoint(), clientRequestId, apiVersion, gitHubAccessTokenRequest, accept, context);
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @param clientRequestId Can provide a guid, which is helpful for debugging and to provide better customer support.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<GitHubAccessTokenResponse> getGitHubAccessTokenAsync(
GitHubAccessTokenRequest gitHubAccessTokenRequest, String clientRequestId) {
return getGitHubAccessTokenWithResponseAsync(gitHubAccessTokenRequest, clientRequestId)
.flatMap(
(Response<GitHubAccessTokenResponse> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<GitHubAccessTokenResponse> getGitHubAccessTokenAsync(
GitHubAccessTokenRequest gitHubAccessTokenRequest) {
final String clientRequestId = null;
return getGitHubAccessTokenWithResponseAsync(gitHubAccessTokenRequest, clientRequestId)
.flatMap(
(Response<GitHubAccessTokenResponse> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @param clientRequestId Can provide a guid, which is helpful for debugging and to provide better customer support.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<GitHubAccessTokenResponse> getGitHubAccessTokenAsync(
GitHubAccessTokenRequest gitHubAccessTokenRequest, String clientRequestId, Context context) {
return getGitHubAccessTokenWithResponseAsync(gitHubAccessTokenRequest, clientRequestId, context)
.flatMap(
(Response<GitHubAccessTokenResponse> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @param clientRequestId Can provide a guid, which is helpful for debugging and to provide better customer support.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public GitHubAccessTokenResponse getGitHubAccessToken(
GitHubAccessTokenRequest gitHubAccessTokenRequest, String clientRequestId) {
return getGitHubAccessTokenAsync(gitHubAccessTokenRequest, clientRequestId).block();
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public GitHubAccessTokenResponse getGitHubAccessToken(GitHubAccessTokenRequest gitHubAccessTokenRequest) {
final String clientRequestId = null;
return getGitHubAccessTokenAsync(gitHubAccessTokenRequest, clientRequestId).block();
}
/**
* Get the GitHub access token.
*
* @param gitHubAccessTokenRequest The gitHubAccessTokenRequest parameter.
* @param clientRequestId Can provide a guid, which is helpful for debugging and to provide better customer support.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the GitHub access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<GitHubAccessTokenResponse> getGitHubAccessTokenWithResponse(
GitHubAccessTokenRequest gitHubAccessTokenRequest, String clientRequestId, Context context) {
return getGitHubAccessTokenWithResponseAsync(gitHubAccessTokenRequest, clientRequestId, context).block();
}
}