/// <summary> /// Initializes a new instance of the <see cref="EventGridPublisherClient"/> class. /// </summary> /// <param name="endpoint">The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events".</param> /// <param name="credential">The Shared Access Signature credential used to connect to Azure. This signature /// can be constructed using the <see cref="EventGridSasBuilder"/>.</param> /// <param name="options">The set of options to use for configuring the client.</param> public EventGridPublisherClient(Uri endpoint, AzureSasCredential credential, EventGridPublisherClientOptions options = default) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new EventGridPublisherClientOptions(); _endpoint = endpoint; HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new EventGridSharedAccessSignatureCredentialPolicy(credential)); _serviceRestClient = new EventGridRestClient(new ClientDiagnostics(options), pipeline, options.Version.GetVersionString()); _clientDiagnostics = new ClientDiagnostics(options); }
/// <summary>Initalizes a new instance of the <see cref="EventGridPublisherClient"/> class.</summary> /// <param name="endpoint">The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events".</param> /// <param name="credential">The key credential used to authenticate with the service.</param> /// <param name="options">The set of options to use for configuring the client.</param> public EventGridPublisherClient(Uri endpoint, AzureKeyCredential credential, EventGridPublisherClientOptions options) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new EventGridPublisherClientOptions(); _apiVersion = options.Version.GetVersionString(); _endpoint = endpoint; _key = credential; _pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.SasKeyName)); _serviceRestClient = new EventGridRestClient(new ClientDiagnostics(options), _pipeline, options.Version.GetVersionString()); _clientDiagnostics = new ClientDiagnostics(options); }
/// <summary> /// Initializes a new instance of the <see cref="EventGridPublisherClient"/> class. /// </summary> /// <param name="endpoint">The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events".</param> /// <param name="credential">The Shared Access Signature credential used to connect to Azure. This signature /// can be constructed using the <see cref="EventGridSasBuilder"/>.</param> /// <param name="options">The set of options to use for configuring the client.</param> public EventGridPublisherClient(Uri endpoint, AzureSasCredential credential, EventGridPublisherClientOptions options = default) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); options ??= new EventGridPublisherClientOptions(); _uriBuilder = new RequestUriBuilder(); _uriBuilder.Reset(endpoint); _uriBuilder.AppendQuery("api-version", options.Version.GetVersionString(), true); _pipeline = HttpPipelineBuilder.Build(options, new EventGridSharedAccessSignatureCredentialPolicy(credential)); _clientDiagnostics = new ClientDiagnostics(options); }
/// <summary>Initalizes a new instance of the <see cref="EventGridPublisherClient"/> class.</summary> /// <param name="endpoint">The topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events".</param> /// <param name="credential">The token credential used to authenticate with the service.</param> /// <param name="options">The set of options to use for configuring the client.</param> public EventGridPublisherClient(Uri endpoint, TokenCredential credential, EventGridPublisherClientOptions options = default) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); options ??= new EventGridPublisherClientOptions(); _uriBuilder = new RequestUriBuilder(); _uriBuilder.Reset(endpoint); _uriBuilder.AppendQuery("api-version", options.Version.GetVersionString(), true); _pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, "https://eventgrid.azure.net/.default")); _clientDiagnostics = new ClientDiagnostics(options); }
/// <summary> /// Initializes a new instance of the <see cref="EventGridPublisherClient"/> class. /// </summary> /// <param name="endpoint">Topic endpoint. For example, "https://TOPIC-NAME.REGION-NAME-1.eventgrid.azure.net/api/events".</param> /// <param name="credential">Credential used to connect to Azure.</param> /// <param name="options">Configuring options.</param> public EventGridPublisherClient(Uri endpoint, EventGridSharedAccessSignatureCredential credential, EventGridPublisherClientOptions options) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new EventGridPublisherClientOptions(); _dataSerializer = options.DataSerializer ?? new JsonObjectSerializer(); _endpoint = endpoint; HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new EventGridSharedAccessSignatureCredentialPolicy(credential)); _serviceRestClient = new ServiceRestClient(new ClientDiagnostics(options), pipeline, options.Version.GetVersionString()); _clientDiagnostics = new ClientDiagnostics(options); }