diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClient.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClient.cs
new file mode 100644
index 000000000000..79ba8701f09f
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClient.cs
@@ -0,0 +1,172 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Serialization;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Net;
+ using System.Net.Http;
+
+ public partial class AzureMessagingWebPubSubServiceClient : ServiceClient, IAzureMessagingWebPubSubServiceClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ public System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ public JsonSerializerSettings SerializationSettings { get; private set; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ public JsonSerializerSettings DeserializationSettings { get; private set; }
+
+ ///
+ /// Gets the IHealthApi.
+ ///
+ public virtual IHealthApi HealthApi { get; private set; }
+
+ ///
+ /// Gets the IWebPubSubOperations.
+ ///
+ public virtual IWebPubSubOperations WebPubSub { get; private set; }
+
+ ///
+ /// Initializes a new instance of the AzureMessagingWebPubSubServiceClient class.
+ ///
+ ///
+ /// HttpClient to be used
+ ///
+ ///
+ /// True: will dispose the provided httpClient on calling AzureMessagingWebPubSubServiceClient.Dispose(). False: will not dispose provided httpClient
+ public AzureMessagingWebPubSubServiceClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureMessagingWebPubSubServiceClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ public AzureMessagingWebPubSubServiceClient(params DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureMessagingWebPubSubServiceClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ public AzureMessagingWebPubSubServiceClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the AzureMessagingWebPubSubServiceClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureMessagingWebPubSubServiceClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the AzureMessagingWebPubSubServiceClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public AzureMessagingWebPubSubServiceClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ HealthApi = new HealthApi(this);
+ WebPubSub = new WebPubSubOperations(this);
+ BaseUri = new System.Uri("http://localhost");
+ SerializationSettings = new JsonSerializerSettings
+ {
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ DeserializationSettings = new JsonSerializerSettings
+ {
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ CustomInitialize();
+ }
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApi.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApi.cs
new file mode 100644
index 000000000000..68ef84269fd5
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApi.cs
@@ -0,0 +1,165 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Microsoft.Rest;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// HealthApi operations.
+ ///
+ public partial class HealthApi : IServiceOperations, IHealthApi
+ {
+ ///
+ /// Initializes a new instance of the HealthApi class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public HealthApi(AzureMessagingWebPubSubServiceClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the AzureMessagingWebPubSubServiceClient
+ ///
+ public AzureMessagingWebPubSubServiceClient Client { get; private set; }
+
+ ///
+ /// Get service health status.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task GetServiceStatusWithHttpMessagesAsync(string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetServiceStatus", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/health").ToString();
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiClient.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiClient.cs
deleted file mode 100644
index d22e7d80c8ce..000000000000
--- a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiClient.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-
-namespace Azure.Messaging.WebPubSub
-{
- /// The HealthApi service client.
- internal partial class HealthApiClient
- {
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- public virtual HttpPipeline Pipeline { get; }
- private Uri endpoint;
- private readonly string apiVersion;
- private readonly ClientDiagnostics _clientDiagnostics;
-
- /// Initializes a new instance of HealthApiClient for mocking.
- protected HealthApiClient()
- {
- }
-
- /// Initializes a new instance of HealthApiClient.
- /// server parameter.
- /// The options for configuring the client.
- public HealthApiClient(Uri endpoint = null, WebPubSubServiceClientOptions options = null)
- {
- endpoint ??= new Uri("");
-
- options ??= new WebPubSubServiceClientOptions();
- _clientDiagnostics = new ClientDiagnostics(options);
- Pipeline = HttpPipelineBuilder.Build(options, new HttpPipelinePolicy[] { new LowLevelCallbackPolicy() }, Array.Empty(), new ResponseClassifier());
- this.endpoint = endpoint;
- apiVersion = options.Version;
- }
-
- /// Get service health status.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task GetServiceStatusAsync(RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateGetServiceStatusRequest(options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("HealthApiClient.GetServiceStatus");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Get service health status.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response GetServiceStatus(RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateGetServiceStatusRequest(options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("HealthApiClient.GetServiceStatus");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The request options.
- private HttpMessage CreateGetServiceStatusRequest(RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Head;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/health", false);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
- }
-}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiExtensions.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiExtensions.cs
new file mode 100644
index 000000000000..a56f3fc62029
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiExtensions.cs
@@ -0,0 +1,54 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for HealthApi.
+ ///
+ public static partial class HealthApiExtensions
+ {
+ ///
+ /// Get service health status.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void GetServiceStatus(this IHealthApi operations, string apiVersion = "2021-05-01-preview")
+ {
+ operations.GetServiceStatusAsync(apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get service health status.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetServiceStatusAsync(this IHealthApi operations, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.GetServiceStatusWithHttpMessagesAsync(apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IAzureMessagingWebPubSubServiceClient.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IAzureMessagingWebPubSubServiceClient.cs
new file mode 100644
index 000000000000..008eff90d136
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IAzureMessagingWebPubSubServiceClient.cs
@@ -0,0 +1,47 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Models;
+ using Newtonsoft.Json;
+
+ ///
+ ///
+ public partial interface IAzureMessagingWebPubSubServiceClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+
+ ///
+ /// Gets the IHealthApi.
+ ///
+ IHealthApi HealthApi { get; }
+
+ ///
+ /// Gets the IWebPubSubOperations.
+ ///
+ IWebPubSubOperations WebPubSub { get; }
+
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IHealthApi.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IHealthApi.cs
new file mode 100644
index 000000000000..c33bd8797dbe
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IHealthApi.cs
@@ -0,0 +1,42 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Microsoft.Rest;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// HealthApi operations.
+ ///
+ public partial interface IHealthApi
+ {
+ ///
+ /// Get service health status.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ Task GetServiceStatusWithHttpMessagesAsync(string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IWebPubSubOperations.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IWebPubSubOperations.cs
new file mode 100644
index 000000000000..344dbe74ddbd
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IWebPubSubOperations.cs
@@ -0,0 +1,510 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Microsoft.Rest;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// WebPubSubOperations operations.
+ ///
+ public partial interface IWebPubSubOperations
+ {
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task SendToAllWithHttpMessagesAsync(string hub, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task ConnectionExistsWithHttpMessagesAsync(string hub, string connectionId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task CloseConnectionWithHttpMessagesAsync(string hub, string connectionId, string reason = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task SendToConnectionWithHttpMessagesAsync(string hub, string connectionId, string message, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less
+ /// than 1025.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task GroupExistsWithHttpMessagesAsync(string hub, string group, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less
+ /// than 1025.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task SendToGroupWithHttpMessagesAsync(string hub, string group, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less
+ /// than 1025.
+ ///
+ ///
+ /// Target connection Id
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task AddConnectionToGroupWithHttpMessagesAsync(string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less
+ /// than 1025.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task RemoveConnectionFromGroupWithHttpMessagesAsync(string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Check if there are any client connections connected for the given
+ /// user.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task UserExistsWithHttpMessagesAsync(string hub, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task SendToUserWithHttpMessagesAsync(string hub, string userId, string message, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less
+ /// than 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task AddUserToGroupWithHttpMessagesAsync(string hub, string group, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less
+ /// than 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task RemoveUserFromGroupWithHttpMessagesAsync(string hub, string group, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task RemoveUserFromAllGroupsWithHttpMessagesAsync(string hub, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup',
+ /// 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter
+ /// standing for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task GrantPermissionWithHttpMessagesAsync(string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup',
+ /// 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter
+ /// standing for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task RevokePermissionWithHttpMessagesAsync(string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup',
+ /// 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter
+ /// standing for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task CheckPermissionWithHttpMessagesAsync(string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/Models/WebPubSubPermission.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/Models/WebPubSubPermission.cs
new file mode 100644
index 000000000000..16de7b38bf7d
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/Models/WebPubSubPermission.cs
@@ -0,0 +1,22 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub.Models
+{
+
+ ///
+ /// Defines values for WebPubSubPermission.
+ ///
+ public static class WebPubSubPermission
+ {
+ public const string SendToGroup = "sendToGroup";
+ public const string JoinLeaveGroup = "joinLeaveGroup";
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/SdkInfo_AzureMessagingWebPubSubServiceClient.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/SdkInfo_AzureMessagingWebPubSubServiceClient.cs
new file mode 100644
index 000000000000..2dea73e3e24d
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/SdkInfo_AzureMessagingWebPubSubServiceClient.cs
@@ -0,0 +1,28 @@
+
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ internal static partial class SdkInfo
+ {
+ public static IEnumerable> ApiInfo_AzureMessagingWebPubSubServiceClient
+ {
+ get
+ {
+ return new Tuple[]
+ {
+ new Tuple("AzureMessagingWebPubSubServiceClient", "HealthApi", "2021-05-01-preview"),
+ new Tuple("AzureMessagingWebPubSubServiceClient", "WebPubSub", "2021-05-01-preview"),
+ }.AsEnumerable();
+ }
+ }
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubOperations.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubOperations.cs
new file mode 100644
index 000000000000..52881a481020
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubOperations.cs
@@ -0,0 +1,2708 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Microsoft.Rest;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// WebPubSubOperations operations.
+ ///
+ public partial class WebPubSubOperations : IServiceOperations, IWebPubSubOperations
+ {
+ ///
+ /// Initializes a new instance of the WebPubSubOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public WebPubSubOperations(AzureMessagingWebPubSubServiceClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the AzureMessagingWebPubSubServiceClient
+ ///
+ public AzureMessagingWebPubSubServiceClient Client { get; private set; }
+
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task SendToAllWithHttpMessagesAsync(string hub, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (message == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "message");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("excluded", excluded);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("message", message);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SendToAll", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/:send").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ List _queryParameters = new List();
+ if (excluded != null)
+ {
+ if (excluded.Count == 0)
+ {
+ _queryParameters.Add(string.Format("excluded={0}", System.Uri.EscapeDataString(string.Empty)));
+ }
+ else
+ {
+ foreach (var _item in excluded)
+ {
+ _queryParameters.Add(string.Format("excluded={0}", System.Uri.EscapeDataString("" + _item)));
+ }
+ }
+ }
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(message != null)
+ {
+ _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(message, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task ConnectionExistsWithHttpMessagesAsync(string hub, string connectionId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ConnectionExists", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 404)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task CloseConnectionWithHttpMessagesAsync(string hub, string connectionId, string reason = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("reason", reason);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CloseConnection", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (reason != null)
+ {
+ _queryParameters.Add(string.Format("reason={0}", System.Uri.EscapeDataString(reason)));
+ }
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task SendToConnectionWithHttpMessagesAsync(string hub, string connectionId, string message, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ if (message == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "message");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("message", message);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SendToConnection", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/connections/{connectionId}/:send").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(message != null)
+ {
+ _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(message, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task GroupExistsWithHttpMessagesAsync(string hub, string group, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (group == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "group");
+ }
+ if (group != null)
+ {
+ if (group.Length > 1024)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "group", 1024);
+ }
+ if (group.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "group", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GroupExists", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/groups/{group}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{group}", System.Uri.EscapeDataString(group));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 404)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task SendToGroupWithHttpMessagesAsync(string hub, string group, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (group == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "group");
+ }
+ if (group != null)
+ {
+ if (group.Length > 1024)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "group", 1024);
+ }
+ if (group.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "group", 1);
+ }
+ }
+ if (message == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "message");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("excluded", excluded);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("message", message);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SendToGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/groups/{group}/:send").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{group}", System.Uri.EscapeDataString(group));
+ List _queryParameters = new List();
+ if (excluded != null)
+ {
+ if (excluded.Count == 0)
+ {
+ _queryParameters.Add(string.Format("excluded={0}", System.Uri.EscapeDataString(string.Empty)));
+ }
+ else
+ {
+ foreach (var _item in excluded)
+ {
+ _queryParameters.Add(string.Format("excluded={0}", System.Uri.EscapeDataString("" + _item)));
+ }
+ }
+ }
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(message != null)
+ {
+ _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(message, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target connection Id
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task AddConnectionToGroupWithHttpMessagesAsync(string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (group == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "group");
+ }
+ if (group != null)
+ {
+ if (group.Length > 1024)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "group", 1024);
+ }
+ if (group.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "group", 1);
+ }
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "AddConnectionToGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/groups/{group}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{group}", System.Uri.EscapeDataString(group));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 404)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task RemoveConnectionFromGroupWithHttpMessagesAsync(string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (group == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "group");
+ }
+ if (group != null)
+ {
+ if (group.Length > 1024)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "group", 1024);
+ }
+ if (group.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "group", 1);
+ }
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "RemoveConnectionFromGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/groups/{group}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{group}", System.Uri.EscapeDataString(group));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if there are any client connections connected for the given user.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task UserExistsWithHttpMessagesAsync(string hub, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (userId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "userId");
+ }
+ if (userId != null)
+ {
+ if (userId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "userId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "UserExists", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/users/{userId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{userId}", System.Uri.EscapeDataString(userId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 404)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task SendToUserWithHttpMessagesAsync(string hub, string userId, string message, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (userId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "userId");
+ }
+ if (userId != null)
+ {
+ if (userId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "userId", 1);
+ }
+ }
+ if (message == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "message");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("message", message);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "SendToUser", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/users/{userId}/:send").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{userId}", System.Uri.EscapeDataString(userId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("POST");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(message != null)
+ {
+ _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(message, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 202)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task AddUserToGroupWithHttpMessagesAsync(string hub, string group, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (group == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "group");
+ }
+ if (group != null)
+ {
+ if (group.Length > 1024)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "group", 1024);
+ }
+ if (group.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "group", 1);
+ }
+ }
+ if (userId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "userId");
+ }
+ if (userId != null)
+ {
+ if (userId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "userId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "AddUserToGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/users/{userId}/groups/{group}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{group}", System.Uri.EscapeDataString(group));
+ _url = _url.Replace("{userId}", System.Uri.EscapeDataString(userId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 404)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task RemoveUserFromGroupWithHttpMessagesAsync(string hub, string group, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (group == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "group");
+ }
+ if (group != null)
+ {
+ if (group.Length > 1024)
+ {
+ throw new ValidationException(ValidationRules.MaxLength, "group", 1024);
+ }
+ if (group.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "group", 1);
+ }
+ }
+ if (userId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "userId");
+ }
+ if (userId != null)
+ {
+ if (userId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "userId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "RemoveUserFromGroup", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/users/{userId}/groups/{group}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{group}", System.Uri.EscapeDataString(group));
+ _url = _url.Replace("{userId}", System.Uri.EscapeDataString(userId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task RemoveUserFromAllGroupsWithHttpMessagesAsync(string hub, string userId, string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (userId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "userId");
+ }
+ if (userId != null)
+ {
+ if (userId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "userId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "RemoveUserFromAllGroups", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/users/{userId}/groups").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{userId}", System.Uri.EscapeDataString(userId));
+ List _queryParameters = new List();
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task GrantPermissionWithHttpMessagesAsync(string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (permission == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "permission");
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("permission", permission);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("targetName", targetName);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GrantPermission", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/permissions/{permission}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{permission}", System.Uri.EscapeDataString(permission));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (targetName != null)
+ {
+ _queryParameters.Add(string.Format("targetName={0}", System.Uri.EscapeDataString(targetName)));
+ }
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task RevokePermissionWithHttpMessagesAsync(string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (permission == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "permission");
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("permission", permission);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("targetName", targetName);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "RevokePermission", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/permissions/{permission}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{permission}", System.Uri.EscapeDataString(permission));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (targetName != null)
+ {
+ _queryParameters.Add(string.Format("targetName={0}", System.Uri.EscapeDataString(targetName)));
+ }
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task CheckPermissionWithHttpMessagesAsync(string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (hub == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "hub");
+ }
+ if (hub != null)
+ {
+ if (!System.Text.RegularExpressions.Regex.IsMatch(hub, "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"))
+ {
+ throw new ValidationException(ValidationRules.Pattern, "hub", "^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$");
+ }
+ }
+ if (permission == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "permission");
+ }
+ if (connectionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "connectionId");
+ }
+ if (connectionId != null)
+ {
+ if (connectionId.Length < 1)
+ {
+ throw new ValidationException(ValidationRules.MinLength, "connectionId", 1);
+ }
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("permission", permission);
+ tracingParameters.Add("connectionId", connectionId);
+ tracingParameters.Add("targetName", targetName);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CheckPermission", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/hubs/{hub}/permissions/{permission}/connections/{connectionId}").ToString();
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{permission}", System.Uri.EscapeDataString(permission));
+ _url = _url.Replace("{connectionId}", System.Uri.EscapeDataString(connectionId));
+ List _queryParameters = new List();
+ if (targetName != null)
+ {
+ _queryParameters.Add(string.Format("targetName={0}", System.Uri.EscapeDataString(targetName)));
+ }
+ if (apiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += "?" + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("HEAD");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 404)
+ {
+ var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ if (_httpResponse.Content != null) {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ }
+ else {
+ _responseContent = string.Empty;
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new HttpOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubOperationsExtensions.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubOperationsExtensions.cs
new file mode 100644
index 000000000000..03568dd973cc
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubOperationsExtensions.cs
@@ -0,0 +1,873 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Azure.Messaging.WebPubSub
+{
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for WebPubSubOperations.
+ ///
+ public static partial class WebPubSubOperationsExtensions
+ {
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void SendToAll(this IWebPubSubOperations operations, string hub, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview")
+ {
+ operations.SendToAllAsync(hub, message, excluded, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToAllAsync(this IWebPubSubOperations operations, string hub, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.SendToAllWithHttpMessagesAsync(hub, message, excluded, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void ConnectionExists(this IWebPubSubOperations operations, string hub, string connectionId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.ConnectionExistsAsync(hub, connectionId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ConnectionExistsAsync(this IWebPubSubOperations operations, string hub, string connectionId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.ConnectionExistsWithHttpMessagesAsync(hub, connectionId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void CloseConnection(this IWebPubSubOperations operations, string hub, string connectionId, string reason = default(string), string apiVersion = "2021-05-01-preview")
+ {
+ operations.CloseConnectionAsync(hub, connectionId, reason, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CloseConnectionAsync(this IWebPubSubOperations operations, string hub, string connectionId, string reason = default(string), string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.CloseConnectionWithHttpMessagesAsync(hub, connectionId, reason, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void SendToConnection(this IWebPubSubOperations operations, string hub, string connectionId, string message, string apiVersion = "2021-05-01-preview")
+ {
+ operations.SendToConnectionAsync(hub, connectionId, message, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The connection Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToConnectionAsync(this IWebPubSubOperations operations, string hub, string connectionId, string message, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.SendToConnectionWithHttpMessagesAsync(hub, connectionId, message, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void GroupExists(this IWebPubSubOperations operations, string hub, string group, string apiVersion = "2021-05-01-preview")
+ {
+ operations.GroupExistsAsync(hub, group, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GroupExistsAsync(this IWebPubSubOperations operations, string hub, string group, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.GroupExistsWithHttpMessagesAsync(hub, group, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void SendToGroup(this IWebPubSubOperations operations, string hub, string group, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview")
+ {
+ operations.SendToGroupAsync(hub, group, message, excluded, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToGroupAsync(this IWebPubSubOperations operations, string hub, string group, string message, IList excluded = default(IList), string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.SendToGroupWithHttpMessagesAsync(hub, group, message, excluded, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target connection Id
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void AddConnectionToGroup(this IWebPubSubOperations operations, string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.AddConnectionToGroupAsync(hub, group, connectionId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target connection Id
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task AddConnectionToGroupAsync(this IWebPubSubOperations operations, string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.AddConnectionToGroupWithHttpMessagesAsync(hub, group, connectionId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void RemoveConnectionFromGroup(this IWebPubSubOperations operations, string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.RemoveConnectionFromGroupAsync(hub, group, connectionId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task RemoveConnectionFromGroupAsync(this IWebPubSubOperations operations, string hub, string group, string connectionId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.RemoveConnectionFromGroupWithHttpMessagesAsync(hub, group, connectionId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Check if there are any client connections connected for the given user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void UserExists(this IWebPubSubOperations operations, string hub, string userId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.UserExistsAsync(hub, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if there are any client connections connected for the given user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task UserExistsAsync(this IWebPubSubOperations operations, string hub, string userId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.UserExistsWithHttpMessagesAsync(hub, userId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void SendToUser(this IWebPubSubOperations operations, string hub, string userId, string message, string apiVersion = "2021-05-01-preview")
+ {
+ operations.SendToUserAsync(hub, userId, message, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToUserAsync(this IWebPubSubOperations operations, string hub, string userId, string message, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.SendToUserWithHttpMessagesAsync(hub, userId, message, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void AddUserToGroup(this IWebPubSubOperations operations, string hub, string group, string userId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.AddUserToGroupAsync(hub, group, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task AddUserToGroupAsync(this IWebPubSubOperations operations, string hub, string group, string userId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.AddUserToGroupWithHttpMessagesAsync(hub, group, userId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void RemoveUserFromGroup(this IWebPubSubOperations operations, string hub, string group, string userId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.RemoveUserFromGroupAsync(hub, group, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target group name, which length should be greater than 0 and less than
+ /// 1025.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task RemoveUserFromGroupAsync(this IWebPubSubOperations operations, string hub, string group, string userId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.RemoveUserFromGroupWithHttpMessagesAsync(hub, group, userId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void RemoveUserFromAllGroups(this IWebPubSubOperations operations, string hub, string userId, string apiVersion = "2021-05-01-preview")
+ {
+ operations.RemoveUserFromAllGroupsAsync(hub, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task RemoveUserFromAllGroupsAsync(this IWebPubSubOperations operations, string hub, string userId, string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.RemoveUserFromAllGroupsWithHttpMessagesAsync(hub, userId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void GrantPermission(this IWebPubSubOperations operations, string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview")
+ {
+ operations.GrantPermissionAsync(hub, permission, connectionId, targetName, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GrantPermissionAsync(this IWebPubSubOperations operations, string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.GrantPermissionWithHttpMessagesAsync(hub, permission, connectionId, targetName, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void RevokePermission(this IWebPubSubOperations operations, string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview")
+ {
+ operations.RevokePermissionAsync(hub, permission, connectionId, targetName, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task RevokePermissionAsync(this IWebPubSubOperations operations, string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.RevokePermissionWithHttpMessagesAsync(hub, permission, connectionId, targetName, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ public static void CheckPermission(this IWebPubSubOperations operations, string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview")
+ {
+ operations.CheckPermissionAsync(hub, permission, connectionId, targetName, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The permission: current supported actions are joinLeaveGroup and
+ /// sendToGroup. Possible values include: 'sendToGroup', 'joinLeaveGroup'
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CheckPermissionAsync(this IWebPubSubOperations operations, string hub, string permission, string connectionId, string targetName = default(string), string apiVersion = "2021-05-01-preview", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.CheckPermissionWithHttpMessagesAsync(hub, permission, connectionId, targetName, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubServiceClient.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubServiceClient.cs
deleted file mode 100644
index 839bb09c927e..000000000000
--- a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/WebPubSubServiceClient.cs
+++ /dev/null
@@ -1,1785 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core;
-using Azure.Core.Pipeline;
-
-namespace Azure.Messaging.WebPubSub
-{
- /// The WebPubSubService service client.
- public partial class WebPubSubServiceClient
- {
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- public virtual HttpPipeline Pipeline { get; }
- private string hub;
- private Uri endpoint;
- private readonly string apiVersion;
- private readonly ClientDiagnostics _clientDiagnostics;
-
- /// Initializes a new instance of WebPubSubServiceClient for mocking.
- protected WebPubSubServiceClient()
- {
- }
-
- /// Broadcast content inside request body to all the connected client connections.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// Excluded connection Ids.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task SendToAllAsync(RequestContent content, ContentType contentType, IEnumerable excluded = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToAllRequest(content, contentType, excluded, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToAll");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Broadcast content inside request body to all the connected client connections.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// Excluded connection Ids.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response SendToAll(RequestContent content, ContentType contentType, IEnumerable excluded = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToAllRequest(content, contentType, excluded, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToAll");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// Excluded connection Ids.
- /// The request options.
- private HttpMessage CreateSendToAllRequest(RequestContent content, ContentType contentType, IEnumerable excluded = null, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Post;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/:send", false);
- if (excluded != null)
- {
- uri.AppendQueryDelimited("excluded", excluded, ",", true);
- }
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- request.Headers.Add("Content-Type", contentType.ToString());
- request.Content = content;
- return message;
- }
-
- /// Check if the connection with the given connectionId exists.
- /// The connection Id.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual async Task ConnectionExistsImplAsync(string connectionId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateConnectionExistsImplRequest(connectionId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.ConnectionExistsImpl");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Check if the connection with the given connectionId exists.
- /// The connection Id.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual Response ConnectionExistsImpl(string connectionId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateConnectionExistsImplRequest(connectionId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.ConnectionExistsImpl");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The connection Id.
- /// The request options.
- private HttpMessage CreateConnectionExistsImplRequest(string connectionId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Head;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Close the client connection.
- /// Target connection Id.
- /// The reason closing the client connection.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task CloseConnectionAsync(string connectionId, string reason = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateCloseConnectionRequest(connectionId, reason, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.CloseConnection");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Close the client connection.
- /// Target connection Id.
- /// The reason closing the client connection.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response CloseConnection(string connectionId, string reason = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateCloseConnectionRequest(connectionId, reason, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.CloseConnection");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target connection Id.
- /// The reason closing the client connection.
- /// The request options.
- private HttpMessage CreateCloseConnectionRequest(string connectionId, string reason = null, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Delete;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (reason != null)
- {
- uri.AppendQuery("reason", reason, true);
- }
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Send content inside request body to the specific connection.
- /// The connection Id.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task SendToConnectionAsync(string connectionId, RequestContent content, ContentType contentType, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToConnectionRequest(connectionId, content, contentType, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToConnection");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Send content inside request body to the specific connection.
- /// The connection Id.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response SendToConnection(string connectionId, RequestContent content, ContentType contentType, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToConnectionRequest(connectionId, content, contentType, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToConnection");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The connection Id.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// The request options.
- private HttpMessage CreateSendToConnectionRequest(string connectionId, RequestContent content, ContentType contentType, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Post;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- uri.AppendPath("/:send", false);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- request.Headers.Add("Content-Type", contentType.ToString());
- request.Content = content;
- return message;
- }
-
- /// Check if there are any client connections inside the given group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual async Task GroupExistsImplAsync(string group, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateGroupExistsImplRequest(group, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.GroupExistsImpl");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Check if there are any client connections inside the given group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual Response GroupExistsImpl(string group, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateGroupExistsImplRequest(group, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.GroupExistsImpl");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// The request options.
- private HttpMessage CreateGroupExistsImplRequest(string group, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Head;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/groups/", false);
- uri.AppendPath(group, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Send content inside request body to a group of connections.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// Excluded connection Ids.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task SendToGroupAsync(string group, RequestContent content, ContentType contentType, IEnumerable excluded = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToGroupRequest(group, content, contentType, excluded, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToGroup");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Send content inside request body to a group of connections.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// Excluded connection Ids.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response SendToGroup(string group, RequestContent content, ContentType contentType, IEnumerable excluded = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToGroupRequest(group, content, contentType, excluded, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToGroup");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// Excluded connection Ids.
- /// The request options.
- private HttpMessage CreateSendToGroupRequest(string group, RequestContent content, ContentType contentType, IEnumerable excluded = null, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Post;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/groups/", false);
- uri.AppendPath(group, true);
- uri.AppendPath("/:send", false);
- if (excluded != null)
- {
- uri.AppendQueryDelimited("excluded", excluded, ",", true);
- }
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- request.Headers.Add("Content-Type", contentType.ToString());
- request.Content = content;
- return message;
- }
-
- /// Add a connection to the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target connection Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task AddConnectionToGroupAsync(string group, string connectionId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateAddConnectionToGroupRequest(group, connectionId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.AddConnectionToGroup");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Add a connection to the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target connection Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response AddConnectionToGroup(string group, string connectionId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateAddConnectionToGroupRequest(group, connectionId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.AddConnectionToGroup");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target connection Id.
- /// The request options.
- private HttpMessage CreateAddConnectionToGroupRequest(string group, string connectionId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Put;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/groups/", false);
- uri.AppendPath(group, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Remove a connection from the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target connection Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task RemoveConnectionFromGroupAsync(string group, string connectionId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRemoveConnectionFromGroupRequest(group, connectionId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RemoveConnectionFromGroup");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Remove a connection from the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target connection Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response RemoveConnectionFromGroup(string group, string connectionId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRemoveConnectionFromGroupRequest(group, connectionId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RemoveConnectionFromGroup");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target connection Id.
- /// The request options.
- private HttpMessage CreateRemoveConnectionFromGroupRequest(string group, string connectionId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Delete;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/groups/", false);
- uri.AppendPath(group, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Check if there are any client connections connected for the given user.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual async Task UserExistsImplAsync(string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateUserExistsImplRequest(userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.UserExistsImpl");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Check if there are any client connections connected for the given user.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual Response UserExistsImpl(string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateUserExistsImplRequest(userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.UserExistsImpl");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target user Id.
- /// The request options.
- private HttpMessage CreateUserExistsImplRequest(string userId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Head;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/users/", false);
- uri.AppendPath(userId, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Send content inside request body to the specific user.
- /// The user Id.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task SendToUserAsync(string userId, RequestContent content, ContentType contentType, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToUserRequest(userId, content, contentType, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToUser");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Send content inside request body to the specific user.
- /// The user Id.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response SendToUser(string userId, RequestContent content, ContentType contentType, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateSendToUserRequest(userId, content, contentType, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.SendToUser");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 202:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The user Id.
- /// The content to send as the body of the request.
- /// Upload file type.
- /// The request options.
- private HttpMessage CreateSendToUserRequest(string userId, RequestContent content, ContentType contentType, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Post;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/users/", false);
- uri.AppendPath(userId, true);
- uri.AppendPath("/:send", false);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- request.Headers.Add("Content-Type", contentType.ToString());
- request.Content = content;
- return message;
- }
-
- /// Add a user to the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task AddUserToGroupAsync(string group, string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateAddUserToGroupRequest(group, userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.AddUserToGroup");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Add a user to the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response AddUserToGroup(string group, string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateAddUserToGroupRequest(group, userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.AddUserToGroup");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target user Id.
- /// The request options.
- private HttpMessage CreateAddUserToGroupRequest(string group, string userId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Put;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/users/", false);
- uri.AppendPath(userId, true);
- uri.AppendPath("/groups/", false);
- uri.AppendPath(group, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Remove a user from the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task RemoveUserFromGroupAsync(string group, string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRemoveUserFromGroupRequest(group, userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RemoveUserFromGroup");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Remove a user from the target group.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response RemoveUserFromGroup(string group, string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRemoveUserFromGroupRequest(group, userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RemoveUserFromGroup");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target group name, which length should be greater than 0 and less than 1025.
- /// Target user Id.
- /// The request options.
- private HttpMessage CreateRemoveUserFromGroupRequest(string group, string userId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Delete;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/users/", false);
- uri.AppendPath(userId, true);
- uri.AppendPath("/groups/", false);
- uri.AppendPath(group, true);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Remove a user from all groups.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual async Task RemoveUserFromAllGroupsAsync(string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRemoveUserFromAllGroupsRequest(userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RemoveUserFromAllGroups");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Remove a user from all groups.
- /// Target user Id.
- /// The request options.
-#pragma warning disable AZC0002
- public virtual Response RemoveUserFromAllGroups(string userId, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRemoveUserFromAllGroupsRequest(userId, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RemoveUserFromAllGroups");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// Target user Id.
- /// The request options.
- private HttpMessage CreateRemoveUserFromAllGroupsRequest(string userId, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Delete;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/users/", false);
- uri.AppendPath(userId, true);
- uri.AppendPath("/groups", false);
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Grant permission to the connection.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, grant the permission to all the targets. If set, grant the permission to the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual async Task GrantPermissionAsync(string permission, string connectionId, string targetName = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateGrantPermissionRequest(permission, connectionId, targetName, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.GrantPermission");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Grant permission to the connection.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, grant the permission to all the targets. If set, grant the permission to the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual Response GrantPermission(string permission, string connectionId, string targetName = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateGrantPermissionRequest(permission, connectionId, targetName, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.GrantPermission");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, grant the permission to all the targets. If set, grant the permission to the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
- private HttpMessage CreateGrantPermissionRequest(string permission, string connectionId, string targetName = null, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Put;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/permissions/", false);
- uri.AppendPath(permission, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (targetName != null)
- {
- uri.AppendQuery("targetName", targetName, true);
- }
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Revoke permission for the connection.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, revoke the permission for all targets. If set, revoke the permission for the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual async Task RevokePermissionAsync(string permission, string connectionId, string targetName = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRevokePermissionRequest(permission, connectionId, targetName, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RevokePermission");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Revoke permission for the connection.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, revoke the permission for all targets. If set, revoke the permission for the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual Response RevokePermission(string permission, string connectionId, string targetName = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateRevokePermissionRequest(permission, connectionId, targetName, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.RevokePermission");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, revoke the permission for all targets. If set, revoke the permission for the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
- private HttpMessage CreateRevokePermissionRequest(string permission, string connectionId, string targetName = null, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Delete;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/permissions/", false);
- uri.AppendPath(permission, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (targetName != null)
- {
- uri.AppendQuery("targetName", targetName, true);
- }
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
-
- /// Check if a connection has permission to the specified action.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, get the permission for all targets. If set, get the permission for the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual async Task CheckPermissionAsync(string permission, string connectionId, string targetName = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateCheckPermissionRequest(permission, connectionId, targetName, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.CheckPermission");
- scope.Start();
- try
- {
- await Pipeline.SendAsync(message, options.CancellationToken).ConfigureAwait(false);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Check if a connection has permission to the specified action.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, get the permission for all targets. If set, get the permission for the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
-#pragma warning disable AZC0002
- internal virtual Response CheckPermission(string permission, string connectionId, string targetName = null, RequestOptions options = null)
-#pragma warning restore AZC0002
- {
- options ??= new RequestOptions();
- HttpMessage message = CreateCheckPermissionRequest(permission, connectionId, targetName, options);
- if (options.PerCallPolicy != null)
- {
- message.SetProperty("RequestOptionsPerCallPolicyCallback", options.PerCallPolicy);
- }
- using var scope = _clientDiagnostics.CreateScope("WebPubSubServiceClient.CheckPermission");
- scope.Start();
- try
- {
- Pipeline.Send(message, options.CancellationToken);
- if (options.StatusOption == ResponseStatusOption.Default)
- {
- switch (message.Response.Status)
- {
- case 200:
- case 404:
- return message.Response;
- default:
- throw _clientDiagnostics.CreateRequestFailedException(message.Response);
- }
- }
- else
- {
- return message.Response;
- }
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Create Request for and operations.
- /// The permission: current supported actions are joinLeaveGroup and sendToGroup.
- /// Target connection Id.
- /// Optional. If not set, get the permission for all targets. If set, get the permission for the specific target. The meaning of the target depends on the specific permission.
- /// The request options.
- private HttpMessage CreateCheckPermissionRequest(string permission, string connectionId, string targetName = null, RequestOptions options = null)
- {
- var message = Pipeline.CreateMessage();
- var request = message.Request;
- request.Method = RequestMethod.Head;
- var uri = new RawRequestUriBuilder();
- uri.Reset(endpoint);
- uri.AppendPath("/api/hubs/", false);
- uri.AppendPath(hub, true);
- uri.AppendPath("/permissions/", false);
- uri.AppendPath(permission, true);
- uri.AppendPath("/connections/", false);
- uri.AppendPath(connectionId, true);
- if (targetName != null)
- {
- uri.AppendQuery("targetName", targetName, true);
- }
- if (apiVersion != null)
- {
- uri.AppendQuery("api-version", apiVersion, true);
- }
- request.Uri = uri;
- return message;
- }
- }
-}