forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeGen from PR 29208 in Azure/azure-rest-api-specs
Merge e2e15f6d436a5fc8d68e6eda7f95c8ba059251a1 into bf9738223ed8c1c25485980b74cfb8ef4158b847
- Loading branch information
SDKAuto
committed
Jun 3, 2024
1 parent
d0c603d
commit 2cb0420
Showing
20 changed files
with
3,975 additions
and
59 deletions.
There are no files selected for viewing
552 changes: 552 additions & 0 deletions
552
.../src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverAsyncClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
543 changes: 543 additions & 0 deletions
543
...paces/src/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
348 changes: 348 additions & 0 deletions
348
...rc/main/java/com/azure/messaging/eventgrid/namespaces/EventGridReceiverClientBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,348 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) TypeSpec Code Generator. | ||
package com.azure.messaging.eventgrid.namespaces; | ||
|
||
import com.azure.core.annotation.Generated; | ||
import com.azure.core.annotation.ServiceClientBuilder; | ||
import com.azure.core.client.traits.ConfigurationTrait; | ||
import com.azure.core.client.traits.EndpointTrait; | ||
import com.azure.core.client.traits.HttpTrait; | ||
import com.azure.core.client.traits.KeyCredentialTrait; | ||
import com.azure.core.client.traits.TokenCredentialTrait; | ||
import com.azure.core.credential.KeyCredential; | ||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.core.http.HttpClient; | ||
import com.azure.core.http.HttpHeaders; | ||
import com.azure.core.http.HttpPipeline; | ||
import com.azure.core.http.HttpPipelineBuilder; | ||
import com.azure.core.http.HttpPipelinePosition; | ||
import com.azure.core.http.policy.AddDatePolicy; | ||
import com.azure.core.http.policy.AddHeadersFromContextPolicy; | ||
import com.azure.core.http.policy.AddHeadersPolicy; | ||
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; | ||
import com.azure.core.http.policy.HttpLoggingPolicy; | ||
import com.azure.core.http.policy.HttpLogOptions; | ||
import com.azure.core.http.policy.HttpPipelinePolicy; | ||
import com.azure.core.http.policy.HttpPolicyProviders; | ||
import com.azure.core.http.policy.KeyCredentialPolicy; | ||
import com.azure.core.http.policy.RequestIdPolicy; | ||
import com.azure.core.http.policy.RetryOptions; | ||
import com.azure.core.http.policy.RetryPolicy; | ||
import com.azure.core.http.policy.UserAgentPolicy; | ||
import com.azure.core.util.ClientOptions; | ||
import com.azure.core.util.Configuration; | ||
import com.azure.core.util.CoreUtils; | ||
import com.azure.core.util.builder.ClientBuilderUtil; | ||
import com.azure.core.util.logging.ClientLogger; | ||
import com.azure.core.util.serializer.JacksonAdapter; | ||
import com.azure.messaging.eventgrid.namespaces.implementation.EventGridReceiverClientImpl; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* A builder for creating a new instance of the EventGridReceiverClient type. | ||
*/ | ||
@ServiceClientBuilder(serviceClients = { EventGridReceiverClient.class, EventGridReceiverAsyncClient.class }) | ||
public final class EventGridReceiverClientBuilder implements HttpTrait<EventGridReceiverClientBuilder>, | ||
ConfigurationTrait<EventGridReceiverClientBuilder>, TokenCredentialTrait<EventGridReceiverClientBuilder>, | ||
KeyCredentialTrait<EventGridReceiverClientBuilder>, EndpointTrait<EventGridReceiverClientBuilder> { | ||
|
||
@Generated | ||
private static final String SDK_NAME = "name"; | ||
|
||
@Generated | ||
private static final String SDK_VERSION = "version"; | ||
|
||
@Generated | ||
private static final String[] DEFAULT_SCOPES = new String[] { "https://eventgrid.azure.net/.default" }; | ||
|
||
@Generated | ||
private static final Map<String, String> PROPERTIES | ||
= CoreUtils.getProperties("azure-messaging-eventgrid-namespaces.properties"); | ||
|
||
@Generated | ||
private final List<HttpPipelinePolicy> pipelinePolicies; | ||
|
||
/** | ||
* Create an instance of the EventGridReceiverClientBuilder. | ||
*/ | ||
@Generated | ||
public EventGridReceiverClientBuilder() { | ||
this.pipelinePolicies = new ArrayList<>(); | ||
} | ||
|
||
/* | ||
* The HTTP pipeline to send requests through. | ||
*/ | ||
@Generated | ||
private HttpPipeline pipeline; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder pipeline(HttpPipeline pipeline) { | ||
if (this.pipeline != null && pipeline == null) { | ||
LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); | ||
} | ||
this.pipeline = pipeline; | ||
return this; | ||
} | ||
|
||
/* | ||
* The HTTP client used to send the request. | ||
*/ | ||
@Generated | ||
private HttpClient httpClient; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder httpClient(HttpClient httpClient) { | ||
this.httpClient = httpClient; | ||
return this; | ||
} | ||
|
||
/* | ||
* The logging configuration for HTTP requests and responses. | ||
*/ | ||
@Generated | ||
private HttpLogOptions httpLogOptions; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { | ||
this.httpLogOptions = httpLogOptions; | ||
return this; | ||
} | ||
|
||
/* | ||
* The client options such as application ID and custom headers to set on a request. | ||
*/ | ||
@Generated | ||
private ClientOptions clientOptions; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder clientOptions(ClientOptions clientOptions) { | ||
this.clientOptions = clientOptions; | ||
return this; | ||
} | ||
|
||
/* | ||
* The retry options to configure retry policy for failed requests. | ||
*/ | ||
@Generated | ||
private RetryOptions retryOptions; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder retryOptions(RetryOptions retryOptions) { | ||
this.retryOptions = retryOptions; | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { | ||
Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); | ||
pipelinePolicies.add(customPolicy); | ||
return this; | ||
} | ||
|
||
/* | ||
* The configuration store that is used during construction of the service client. | ||
*/ | ||
@Generated | ||
private Configuration configuration; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder configuration(Configuration configuration) { | ||
this.configuration = configuration; | ||
return this; | ||
} | ||
|
||
/* | ||
* The TokenCredential used for authentication. | ||
*/ | ||
@Generated | ||
private TokenCredential tokenCredential; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder credential(TokenCredential tokenCredential) { | ||
this.tokenCredential = tokenCredential; | ||
return this; | ||
} | ||
|
||
/* | ||
* The KeyCredential used for authentication. | ||
*/ | ||
@Generated | ||
private KeyCredential keyCredential; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder credential(KeyCredential keyCredential) { | ||
this.keyCredential = keyCredential; | ||
return this; | ||
} | ||
|
||
/* | ||
* The service endpoint | ||
*/ | ||
@Generated | ||
private String endpoint; | ||
|
||
/** | ||
* {@inheritDoc}. | ||
*/ | ||
@Generated | ||
@Override | ||
public EventGridReceiverClientBuilder endpoint(String endpoint) { | ||
this.endpoint = endpoint; | ||
return this; | ||
} | ||
|
||
/* | ||
* Service version | ||
*/ | ||
@Generated | ||
private EventGridServiceVersion serviceVersion; | ||
|
||
/** | ||
* Sets Service version. | ||
* | ||
* @param serviceVersion the serviceVersion value. | ||
* @return the EventGridReceiverClientBuilder. | ||
*/ | ||
@Generated | ||
public EventGridReceiverClientBuilder serviceVersion(EventGridServiceVersion serviceVersion) { | ||
this.serviceVersion = serviceVersion; | ||
return this; | ||
} | ||
|
||
/* | ||
* The retry policy that will attempt to retry failed requests, if applicable. | ||
*/ | ||
@Generated | ||
private RetryPolicy retryPolicy; | ||
|
||
/** | ||
* Sets The retry policy that will attempt to retry failed requests, if applicable. | ||
* | ||
* @param retryPolicy the retryPolicy value. | ||
* @return the EventGridReceiverClientBuilder. | ||
*/ | ||
@Generated | ||
public EventGridReceiverClientBuilder retryPolicy(RetryPolicy retryPolicy) { | ||
this.retryPolicy = retryPolicy; | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds an instance of EventGridReceiverClientImpl with the provided parameters. | ||
* | ||
* @return an instance of EventGridReceiverClientImpl. | ||
*/ | ||
@Generated | ||
private EventGridReceiverClientImpl buildInnerClient() { | ||
HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); | ||
EventGridServiceVersion localServiceVersion | ||
= (serviceVersion != null) ? serviceVersion : EventGridServiceVersion.getLatest(); | ||
EventGridReceiverClientImpl client = new EventGridReceiverClientImpl(localPipeline, | ||
JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); | ||
return client; | ||
} | ||
|
||
@Generated | ||
private HttpPipeline createHttpPipeline() { | ||
Configuration buildConfiguration | ||
= (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; | ||
HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; | ||
ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; | ||
List<HttpPipelinePolicy> policies = new ArrayList<>(); | ||
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); | ||
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); | ||
String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); | ||
policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); | ||
policies.add(new RequestIdPolicy()); | ||
policies.add(new AddHeadersFromContextPolicy()); | ||
HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); | ||
if (headers != null) { | ||
policies.add(new AddHeadersPolicy(headers)); | ||
} | ||
this.pipelinePolicies.stream() | ||
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) | ||
.forEach(p -> policies.add(p)); | ||
HttpPolicyProviders.addBeforeRetryPolicies(policies); | ||
policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); | ||
policies.add(new AddDatePolicy()); | ||
if (keyCredential != null) { | ||
policies.add(new KeyCredentialPolicy("authorization", keyCredential, "SharedAccessKey")); | ||
} | ||
if (tokenCredential != null) { | ||
policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); | ||
} | ||
this.pipelinePolicies.stream() | ||
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) | ||
.forEach(p -> policies.add(p)); | ||
HttpPolicyProviders.addAfterRetryPolicies(policies); | ||
policies.add(new HttpLoggingPolicy(localHttpLogOptions)); | ||
HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) | ||
.httpClient(httpClient) | ||
.clientOptions(localClientOptions) | ||
.build(); | ||
return httpPipeline; | ||
} | ||
|
||
/** | ||
* Builds an instance of EventGridReceiverAsyncClient class. | ||
* | ||
* @return an instance of EventGridReceiverAsyncClient. | ||
*/ | ||
@Generated | ||
public EventGridReceiverAsyncClient buildAsyncClient() { | ||
return new EventGridReceiverAsyncClient(buildInnerClient()); | ||
} | ||
|
||
/** | ||
* Builds an instance of EventGridReceiverClient class. | ||
* | ||
* @return an instance of EventGridReceiverClient. | ||
*/ | ||
@Generated | ||
public EventGridReceiverClient buildClient() { | ||
return new EventGridReceiverClient(buildInnerClient()); | ||
} | ||
|
||
private static final ClientLogger LOGGER = new ClientLogger(EventGridReceiverClientBuilder.class); | ||
} |
Oops, something went wrong.