Class EventGridPublisherClientBuilder

java.lang.Object
com.azure.messaging.eventgrid.EventGridPublisherClientBuilder
All Implemented Interfaces:
AzureKeyCredentialTrait<EventGridPublisherClientBuilder>, AzureSasCredentialTrait<EventGridPublisherClientBuilder>, ConfigurationTrait<EventGridPublisherClientBuilder>, EndpointTrait<EventGridPublisherClientBuilder>, HttpTrait<EventGridPublisherClientBuilder>, TokenCredentialTrait<EventGridPublisherClientBuilder>

A Builder class to create service clients that can publish events to EventGrid.
See Also:
  • Constructor Details

    • EventGridPublisherClientBuilder

      public EventGridPublisherClientBuilder()
      Construct a new instance with default building settings. The endpoint and one credential method must be set in order for the client to be built.
  • Method Details

    • addPolicy

      public EventGridPublisherClientBuilder addPolicy(HttpPipelinePolicy httpPipelinePolicy)
      Adds a pipeline policy to apply on each request sent.

      Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

      Specified by:
      addPolicy in interface HttpTrait<EventGridPublisherClientBuilder>
      Parameters:
      httpPipelinePolicy - A pipeline policy.
      Returns:
      the builder itself.
    • retryPolicy

      public EventGridPublisherClientBuilder retryPolicy(RetryPolicy retryPolicy)
      Add a custom retry policy to the pipeline. The default is RetryPolicy(). Setting this is mutually exclusive with using retryOptions(RetryOptions).
      Parameters:
      retryPolicy - the retry policy to add.
      Returns:
      the builder itself.
    • retryOptions

      public EventGridPublisherClientBuilder retryOptions(RetryOptions retryOptions)
      Sets the RetryOptions for all the requests made through the client.

      Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

      Setting this is mutually exclusive with using retryPolicy(RetryPolicy).

      Specified by:
      retryOptions in interface HttpTrait<EventGridPublisherClientBuilder>
      Parameters:
      retryOptions - The RetryOptions to use for all the requests made through the client.
      Returns:
      the builder itself.
    • clientOptions

      public EventGridPublisherClientBuilder clientOptions(ClientOptions clientOptions)
      Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is recommended that this method be called with an instance of the HttpClientOptions class (a subclass of the ClientOptions base class). The HttpClientOptions subclass provides more configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait interface.

      Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

      Specified by:
      clientOptions in interface HttpTrait<EventGridPublisherClientBuilder>
      Parameters:
      clientOptions - A configured instance of HttpClientOptions.
      Returns:
      The updated EventGridPublisherClientBuilder object.
      See Also:
    • configuration

      public EventGridPublisherClientBuilder configuration(Configuration configuration)
      Set the configuration of HTTP and Azure values. A default is already set.
      Specified by:
      configuration in interface ConfigurationTrait<EventGridPublisherClientBuilder>
      Parameters:
      configuration - the configuration to use.
      Returns:
      the builder itself.
    • credential

      public EventGridPublisherClientBuilder credential(AzureKeyCredential credential)
      Set the domain or topic authentication using a key obtained from Azure CLI, Azure portal, or the ARM SDKs.
      Specified by:
      credential in interface AzureKeyCredentialTrait<EventGridPublisherClientBuilder>
      Parameters:
      credential - the key credential to use to authorize the publisher client.
      Returns:
      the builder itself.
    • credential

      public EventGridPublisherClientBuilder credential(AzureSasCredential credential)
      Set the domain or topic authentication using an already obtained Shared Access Signature token.
      Specified by:
      credential in interface AzureSasCredentialTrait<EventGridPublisherClientBuilder>
      Parameters:
      credential - the sas credential to use.
      Returns:
      the builder itself.
    • credential

      public EventGridPublisherClientBuilder credential(TokenCredential credential)
      Sets the TokenCredential used to authorize requests sent to the service. Refer to the Azure SDK for Java identity and authentication documentation for more details on proper usage of the TokenCredential type.
      Specified by:
      credential in interface TokenCredentialTrait<EventGridPublisherClientBuilder>
      Parameters:
      credential - TokenCredential used to authorize requests sent to the service.
      Returns:
      the builder itself.
    • endpoint

      public EventGridPublisherClientBuilder endpoint(String endpoint)
      Set the domain or topic endpoint. This is the address to publish events to. It must be the full url of the endpoint instead of just the hostname.
      Specified by:
      endpoint in interface EndpointTrait<EventGridPublisherClientBuilder>
      Parameters:
      endpoint - the endpoint as a url.
      Returns:
      the builder itself.
      Throws:
      NullPointerException - if endpoint is null.
      IllegalArgumentException - if endpoint cannot be parsed into a valid URL.
    • httpClient

      public EventGridPublisherClientBuilder httpClient(HttpClient httpClient)
      Sets the HttpClient to use for sending and receiving requests to and from the service.

      Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

      Specified by:
      httpClient in interface HttpTrait<EventGridPublisherClientBuilder>
      Parameters:
      httpClient - The HttpClient to use for requests.
      Returns:
      the builder itself.
    • httpLogOptions

      public EventGridPublisherClientBuilder httpLogOptions(HttpLogOptions httpLogOptions)
      Sets the logging configuration to use when sending and receiving requests to and from the service. If a logLevel is not provided, default value of HttpLogDetailLevel.NONE is set.

      Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

      Specified by:
      httpLogOptions in interface HttpTrait<EventGridPublisherClientBuilder>
      Parameters:
      httpLogOptions - The logging configuration to use when sending and receiving requests to and from the service.
      Returns:
      the builder itself.
    • pipeline

      public EventGridPublisherClientBuilder pipeline(HttpPipeline httpPipeline)
      Sets the HttpPipeline to use for the service client.

      Note: It is important to understand the precedence order of the HttpTrait APIs. In particular, if a HttpPipeline is specified, this takes precedence over all other APIs in the trait, and they will be ignored. If no HttpPipeline is specified, a HTTP pipeline will be constructed internally based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this trait that are also ignored if an HttpPipeline is specified, so please be sure to refer to the documentation of types that implement this trait to understand the full set of implications.

      Specified by:
      pipeline in interface HttpTrait<EventGridPublisherClientBuilder>
      Parameters:
      httpPipeline - HttpPipeline to use for sending service requests and receiving responses.
      Returns:
      the builder itself.
    • serviceVersion

      public EventGridPublisherClientBuilder serviceVersion(EventGridServiceVersion serviceVersion)
      Set the service version to use for requests to the event grid service. See EventGridServiceVersion for more information about possible service versions.
      Parameters:
      serviceVersion - the service version to set. By default this will use the latest available version.
      Returns:
      the builder itself
    • buildCloudEventPublisherAsyncClient

      public EventGridPublisherAsyncClient<CloudEvent> buildCloudEventPublisherAsyncClient()
      Build a CloudEvent publisher client with asynchronous publishing methods and the current settings. An endpoint must be set, and either a pipeline with correct authentication must be set, or a credential must be set in the form of an AzureSasCredential or a AzureKeyCredential at the respective methods. All other settings have defaults and are optional.
      Returns:
      a publisher client with asynchronous publishing methods.
    • buildEventGridEventPublisherAsyncClient

      public EventGridPublisherAsyncClient<EventGridEvent> buildEventGridEventPublisherAsyncClient()
      Build an EventGridEvent publisher client with asynchronous publishing methods and the current settings. An endpoint must be set, and either a pipeline with correct authentication must be set, or a credential must be set in the form of an AzureSasCredential or a AzureKeyCredential at the respective methods. All other settings have defaults and are optional.
      Returns:
      a publisher client with asynchronous publishing methods.
    • buildCustomEventPublisherAsyncClient

      public EventGridPublisherAsyncClient<BinaryData> buildCustomEventPublisherAsyncClient()
      Build a custom event publisher client with asynchronous publishing methods and the current settings. An endpoint must be set, and either a pipeline with correct authentication must be set, or a credential must be set in the form of an AzureSasCredential or a AzureKeyCredential at the respective methods. All other settings have defaults and are optional.
      Returns:
      a publisher client with asynchronous publishing methods.
    • buildCloudEventPublisherClient

      public EventGridPublisherClient<CloudEvent> buildCloudEventPublisherClient()
      Build a CloudEvent publisher client with synchronous publishing methods and the current settings. Endpoint and a credential must be set (either keyCredential or sharedAccessSignatureCredential), all other settings have defaults and/or are optional.
      Returns:
      a publisher client with synchronous publishing methods.
    • buildEventGridEventPublisherClient

      public EventGridPublisherClient<EventGridEvent> buildEventGridEventPublisherClient()
      Build an EventGridEvent publisher client with synchronous publishing methods and the current settings. Endpoint and a credential must be set (either keyCredential or sharedAccessSignatureCredential), all other settings have defaults and/or are optional.
      Returns:
      a publisher client with synchronous publishing methods.
    • buildCustomEventPublisherClient

      public EventGridPublisherClient<BinaryData> buildCustomEventPublisherClient()
      Build a custom event publisher client with synchronous publishing methods and the current settings. Endpoint and a credential must be set (either keyCredential or sharedAccessSignatureCredential), all other settings have defaults and/or are optional.
      Returns:
      a publisher client with synchronous publishing methods.