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..c5c55485d58a
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClient.cs
@@ -0,0 +1,4142 @@
+//
+// 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;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ public partial class AzureMessagingWebPubSubServiceClient : ServiceClient, IAzureMessagingWebPubSubServiceClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ internal string 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; }
+
+ ///
+ /// 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();
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ BaseUri = "{Endpoint}";
+ 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();
+ }
+ ///
+ /// Generate token for the client to connect Azure Web PubSub service.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// User Id.
+ ///
+ ///
+ /// Roles that the connection with the generated token will have.
+ ///
+ ///
+ /// The expire time of the generated token.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// 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> GetClientAccessTokenWithHttpMessagesAsync(string endpoint, string hub, string apiVersion, string userId = default(string), IList roles = default(IList), int? minutesToExpire = 60, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("roles", roles);
+ tracingParameters.Add("minutesToExpire", minutesToExpire);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "GetClientAccessToken", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/:generateToken";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ List _queryParameters = new List();
+ if (userId != null)
+ {
+ _queryParameters.Add(string.Format("userId={0}", System.Uri.EscapeDataString(userId)));
+ }
+ if (roles != null)
+ {
+ if (roles.Count == 0)
+ {
+ _queryParameters.Add(string.Format("role={0}", System.Uri.EscapeDataString(string.Empty)));
+ }
+ else
+ {
+ foreach (var _item in roles)
+ {
+ _queryParameters.Add(string.Format("role={0}", System.Uri.EscapeDataString("" + _item)));
+ }
+ }
+ }
+ if (minutesToExpire != null)
+ {
+ _queryParameters.Add(string.Format("minutesToExpire={0}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(minutesToExpire, SerializationSettings).Trim('"'))));
+ }
+ 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;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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;
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Close the connections in the hub.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the hub.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// 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> CloseAllConnectionsWithHttpMessagesAsync(string endpoint, string hub, string apiVersion, IList excluded = default(IList), string reason = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("excluded", excluded);
+ tracingParameters.Add("reason", reason);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CloseAllConnections", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/:closeConnections";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 (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("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;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// 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 endpoint, string hub, string apiVersion, string message, IList excluded = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ 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("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/:send";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 = SafeJsonConvert.SerializeObject(message, 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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string connectionId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// 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 endpoint, string hub, string connectionId, string apiVersion, string reason = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 payload body.
+ ///
+ ///
+ /// 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 endpoint, string hub, string connectionId, string apiVersion, string message, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ 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("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/connections/{connectionId}/:send";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 = SafeJsonConvert.SerializeObject(message, 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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string group, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/groups/{group}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Close connections in the specific group.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the group.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// 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> CloseGroupConnectionsWithHttpMessagesAsync(string endpoint, string hub, string group, string apiVersion, IList excluded = default(IList), string reason = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("group", group);
+ tracingParameters.Add("excluded", excluded);
+ tracingParameters.Add("reason", reason);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CloseGroupConnections", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/groups/{group}/:closeConnections";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 (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("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;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ ///
+ /// 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 endpoint, string hub, string group, string apiVersion, string message, IList excluded = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ 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("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/groups/{group}/:send";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 = SafeJsonConvert.SerializeObject(message, 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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string group, string connectionId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/groups/{group}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string group, string connectionId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/groups/{group}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if there are any client connections connected for the given user.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string userId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/users/{userId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Close connections for the specific user.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections for the user.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// 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> CloseUserConnectionsWithHttpMessagesAsync(string endpoint, string hub, string userId, string apiVersion, IList excluded = default(IList), string reason = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ tracingParameters.Add("hub", hub);
+ tracingParameters.Add("userId", userId);
+ tracingParameters.Add("excluded", excluded);
+ tracingParameters.Add("reason", reason);
+ tracingParameters.Add("apiVersion", apiVersion);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CloseUserConnections", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/users/{userId}/:closeConnections";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _url = _url.Replace("{hub}", System.Uri.EscapeDataString(hub));
+ _url = _url.Replace("{userId}", System.Uri.EscapeDataString(userId));
+ 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 (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("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;
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// 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 endpoint, string hub, string userId, string apiVersion, string message, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ 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("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/users/{userId}/:send";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 = SafeJsonConvert.SerializeObject(message, 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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string group, string userId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/users/{userId}/groups/{group}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string group, string userId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/users/{userId}/groups/{group}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 endpoint, string hub, string userId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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 (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/users/{userId}/groups";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// 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 endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/permissions/{permission}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// 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 endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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 = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/permissions/{permission}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ ///
+ /// 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> HasPermissionWithHttpMessagesAsync(string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (endpoint == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "endpoint");
+ }
+ 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);
+ }
+ }
+ if (apiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "apiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("endpoint", endpoint);
+ 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, "HasPermission", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = BaseUri;
+ var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "api/hubs/{hub}/permissions/{permission}/connections/{connectionId}";
+ _url = _url.Replace("{Endpoint}", endpoint);
+ _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 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 ErrorDetailException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorDetail _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ 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 HttpOperationHeaderResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ try
+ {
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings));
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClientExtensions.cs b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClientExtensions.cs
new file mode 100644
index 000000000000..0a085d17b895
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/AzureMessagingWebPubSubServiceClientExtensions.cs
@@ -0,0 +1,1277 @@
+//
+// 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 AzureMessagingWebPubSubServiceClient.
+ ///
+ public static partial class AzureMessagingWebPubSubServiceClientExtensions
+ {
+ ///
+ /// Generate token for the client to connect Azure Web PubSub service.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// User Id.
+ ///
+ ///
+ /// Roles that the connection with the generated token will have.
+ ///
+ ///
+ /// The expire time of the generated token.
+ ///
+ public static ClientTokenResponse GetClientAccessToken(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string apiVersion, string userId = default(string), IList roles = default(IList), int? minutesToExpire = 60)
+ {
+ return operations.GetClientAccessTokenAsync(endpoint, hub, apiVersion, userId, roles, minutesToExpire).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Generate token for the client to connect Azure Web PubSub service.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// User Id.
+ ///
+ ///
+ /// Roles that the connection with the generated token will have.
+ ///
+ ///
+ /// The expire time of the generated token.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetClientAccessTokenAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string apiVersion, string userId = default(string), IList roles = default(IList), int? minutesToExpire = 60, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetClientAccessTokenWithHttpMessagesAsync(endpoint, hub, apiVersion, userId, roles, minutesToExpire, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Close the connections in the hub.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the hub.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ public static CloseAllConnectionsHeaders CloseAllConnections(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string apiVersion, IList excluded = default(IList), string reason = default(string))
+ {
+ return operations.CloseAllConnectionsAsync(endpoint, hub, apiVersion, excluded, reason).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Close the connections in the hub.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the hub.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CloseAllConnectionsAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string apiVersion, IList excluded = default(IList), string reason = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CloseAllConnectionsWithHttpMessagesAsync(endpoint, hub, apiVersion, excluded, reason, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ public static SendToAllHeaders SendToAll(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string apiVersion, string message, IList excluded = default(IList))
+ {
+ return operations.SendToAllAsync(endpoint, hub, apiVersion, message, excluded).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToAllAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string apiVersion, string message, IList excluded = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.SendToAllWithHttpMessagesAsync(endpoint, hub, apiVersion, message, excluded, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 ConnectionExistsHeaders ConnectionExists(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string connectionId, string apiVersion)
+ {
+ return operations.ConnectionExistsAsync(endpoint, hub, connectionId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if the connection with the given connectionId exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string connectionId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ConnectionExistsWithHttpMessagesAsync(endpoint, hub, connectionId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ public static CloseConnectionHeaders CloseConnection(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string connectionId, string apiVersion, string reason = default(string))
+ {
+ return operations.CloseConnectionAsync(endpoint, hub, connectionId, apiVersion, reason).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Close the client connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// Target connection Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CloseConnectionAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string connectionId, string apiVersion, string reason = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CloseConnectionWithHttpMessagesAsync(endpoint, hub, connectionId, apiVersion, reason, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 payload body.
+ ///
+ public static SendToConnectionHeaders SendToConnection(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string connectionId, string apiVersion, string message)
+ {
+ return operations.SendToConnectionAsync(endpoint, hub, connectionId, apiVersion, message).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Send content inside request body to the specific connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 payload body.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToConnectionAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string connectionId, string apiVersion, string message, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.SendToConnectionWithHttpMessagesAsync(endpoint, hub, connectionId, apiVersion, message, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 GroupExistsHeaders GroupExists(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string apiVersion)
+ {
+ return operations.GroupExistsAsync(endpoint, hub, group, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if there are any client connections inside the given group
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GroupExistsWithHttpMessagesAsync(endpoint, hub, group, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Close connections in the specific group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the group.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ public static CloseGroupConnectionsHeaders CloseGroupConnections(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string apiVersion, IList excluded = default(IList), string reason = default(string))
+ {
+ return operations.CloseGroupConnectionsAsync(endpoint, hub, group, apiVersion, excluded, reason).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Close connections in the specific group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the group.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CloseGroupConnectionsAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string apiVersion, IList excluded = default(IList), string reason = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CloseGroupConnectionsWithHttpMessagesAsync(endpoint, hub, group, apiVersion, excluded, reason, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ public static SendToGroupHeaders SendToGroup(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string apiVersion, string message, IList excluded = default(IList))
+ {
+ return operations.SendToGroupAsync(endpoint, hub, group, apiVersion, message, excluded).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Send content inside request body to a group of connections.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 payload body.
+ ///
+ ///
+ /// Excluded connection Ids
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToGroupAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string apiVersion, string message, IList excluded = default(IList), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.SendToGroupWithHttpMessagesAsync(endpoint, hub, group, apiVersion, message, excluded, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 AddConnectionToGroupHeaders AddConnectionToGroup(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string connectionId, string apiVersion)
+ {
+ return operations.AddConnectionToGroupAsync(endpoint, hub, group, connectionId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Add a connection to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string connectionId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.AddConnectionToGroupWithHttpMessagesAsync(endpoint, hub, group, connectionId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 RemoveConnectionFromGroupHeaders RemoveConnectionFromGroup(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string connectionId, string apiVersion)
+ {
+ return operations.RemoveConnectionFromGroupAsync(endpoint, hub, group, connectionId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Remove a connection from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string connectionId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.RemoveConnectionFromGroupWithHttpMessagesAsync(endpoint, hub, group, connectionId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Check if there are any client connections connected for the given user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 UserExistsHeaders UserExists(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion)
+ {
+ return operations.UserExistsAsync(endpoint, hub, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if there are any client connections connected for the given user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.UserExistsWithHttpMessagesAsync(endpoint, hub, userId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Close connections for the specific user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections for the user.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ public static CloseUserConnectionsHeaders CloseUserConnections(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion, IList excluded = default(IList), string reason = default(string))
+ {
+ return operations.CloseUserConnectionsAsync(endpoint, hub, userId, apiVersion, excluded, reason).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Close connections for the specific user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections for the user.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CloseUserConnectionsAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion, IList excluded = default(IList), string reason = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CloseUserConnectionsWithHttpMessagesAsync(endpoint, hub, userId, apiVersion, excluded, reason, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ public static SendToUserHeaders SendToUser(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion, string message)
+ {
+ return operations.SendToUserAsync(endpoint, hub, userId, apiVersion, message).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Send content inside request body to the specific user.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and only
+ /// contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The user Id.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task SendToUserAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion, string message, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.SendToUserWithHttpMessagesAsync(endpoint, hub, userId, apiVersion, message, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 AddUserToGroupHeaders AddUserToGroup(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string userId, string apiVersion)
+ {
+ return operations.AddUserToGroupAsync(endpoint, hub, group, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Add a user to the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string userId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.AddUserToGroupWithHttpMessagesAsync(endpoint, hub, group, userId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 RemoveUserFromGroupHeaders RemoveUserFromGroup(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string userId, string apiVersion)
+ {
+ return operations.RemoveUserFromGroupAsync(endpoint, hub, group, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Remove a user from the target group.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string group, string userId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.RemoveUserFromGroupWithHttpMessagesAsync(endpoint, hub, group, userId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 RemoveUserFromAllGroupsHeaders RemoveUserFromAllGroups(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion)
+ {
+ return operations.RemoveUserFromAllGroupsAsync(endpoint, hub, userId, apiVersion).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Remove a user from all groups.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string userId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.RemoveUserFromAllGroupsWithHttpMessagesAsync(endpoint, hub, userId, apiVersion, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ public static GrantPermissionHeaders GrantPermission(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string))
+ {
+ return operations.GrantPermissionAsync(endpoint, hub, permission, connectionId, apiVersion, targetName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Grant permission to the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// 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 cancellation token.
+ ///
+ public static async Task GrantPermissionAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GrantPermissionWithHttpMessagesAsync(endpoint, hub, permission, connectionId, apiVersion, targetName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ public static RevokePermissionHeaders RevokePermission(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string))
+ {
+ return operations.RevokePermissionAsync(endpoint, hub, permission, connectionId, apiVersion, targetName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Revoke permission for the connection.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// 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 cancellation token.
+ ///
+ public static async Task RevokePermissionAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.RevokePermissionWithHttpMessagesAsync(endpoint, hub, permission, connectionId, apiVersion, targetName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// The meaning of the target depends on the specific permission. For
+ /// joinLeaveGroup and sendToGroup, targetName is a required parameter standing
+ /// for the group name.
+ ///
+ public static HasPermissionHeaders HasPermission(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string))
+ {
+ return operations.HasPermissionAsync(endpoint, hub, permission, connectionId, apiVersion, targetName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Check if a connection has permission to the specified action.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// 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 version of the REST APIs.
+ ///
+ ///
+ /// 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 cancellation token.
+ ///
+ public static async Task HasPermissionAsync(this IAzureMessagingWebPubSubServiceClient operations, string endpoint, string hub, string permission, string connectionId, string apiVersion, string targetName = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.HasPermissionWithHttpMessagesAsync(endpoint, hub, permission, connectionId, apiVersion, targetName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Headers;
+ }
+ }
+
+ }
+}
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 643451170521..000000000000
--- a/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/HealthApiClient.cs
+++ /dev/null
@@ -1,114 +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
- {
- private readonly HttpPipeline _pipeline;
- private readonly string _endpoint;
- private readonly string _apiVersion;
- internal ClientDiagnostics ClientDiagnostics { get; }
- /// The HTTP pipeline for sending and receiving REST requests and responses.
- public virtual HttpPipeline Pipeline => _pipeline;
-
- /// Initializes a new instance of HealthApiClient for mocking.
- protected HealthApiClient()
- {
- }
-
- /// Initializes a new instance of HealthApiClient.
- /// HTTP or HTTPS endpoint for the Web PubSub service instance.
- /// The options for configuring the client.
- /// is null.
- public HealthApiClient(string endpoint, WebPubSubServiceClientOptions options = null)
- {
- Argument.AssertNotNull(endpoint, nameof(endpoint));
- options ??= new WebPubSubServiceClientOptions();
-
- ClientDiagnostics = new ClientDiagnostics(options);
- _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), Array.Empty(), new ResponseClassifier());
- _endpoint = endpoint;
- _apiVersion = options.Version;
- }
-
- /// Get service health status.
- /// The request context, which can override default behaviors on the request on a per-call basis.
-#pragma warning disable AZC0002
- public virtual async Task GetServiceStatusAsync(RequestContext context = null)
-#pragma warning restore AZC0002
- {
- using var scope = ClientDiagnostics.CreateScope("HealthApiClient.GetServiceStatus");
- scope.Start();
- try
- {
- using HttpMessage message = CreateGetServiceStatusRequest(context);
- return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- /// Get service health status.
- /// The request context, which can override default behaviors on the request on a per-call basis.
-#pragma warning disable AZC0002
- public virtual Response GetServiceStatus(RequestContext context = null)
-#pragma warning restore AZC0002
- {
- using var scope = ClientDiagnostics.CreateScope("HealthApiClient.GetServiceStatus");
- scope.Start();
- try
- {
- using HttpMessage message = CreateGetServiceStatusRequest(context);
- return _pipeline.ProcessMessage(message, context);
- }
- catch (Exception e)
- {
- scope.Failed(e);
- throw;
- }
- }
-
- internal HttpMessage CreateGetServiceStatusRequest(RequestContext context)
- {
- var message = _pipeline.CreateMessage(context);
- var request = message.Request;
- request.Method = RequestMethod.Head;
- var uri = new RawRequestUriBuilder();
- uri.AppendRaw(_endpoint, false);
- uri.AppendPath("/api/health", false);
- uri.AppendQuery("api-version", _apiVersion, true);
- request.Uri = uri;
- message.ResponseClassifier = ResponseClassifier200.Instance;
- return message;
- }
-
- private sealed class ResponseClassifier200 : ResponseClassifier
- {
- private static ResponseClassifier _instance;
- public static ResponseClassifier Instance => _instance ??= new ResponseClassifier200();
- public override bool IsErrorResponse(HttpMessage message)
- {
- return message.Response.Status switch
- {
- 200 => false,
- _ => true
- };
- }
- }
- }
-}
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..685a035fc3e1
--- /dev/null
+++ b/sdk/webpubsub/Azure.Messaging.WebPubSub/src/Generated/IAzureMessagingWebPubSubServiceClient.cs
@@ -0,0 +1,614 @@
+//
+// 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 Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ ///
+ public partial interface IAzureMessagingWebPubSubServiceClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+
+ ///
+ /// Generate token for the client to connect Azure Web PubSub service.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// User Id.
+ ///
+ ///
+ /// Roles that the connection with the generated token will have.
+ ///
+ ///
+ /// The expire time of the generated token.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> GetClientAccessTokenWithHttpMessagesAsync(string endpoint, string hub, string apiVersion, string userId = default(string), IList roles = default(IList), int? minutesToExpire = 60, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Close the connections in the hub.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// Exclude these connectionIds when closing the connections in the
+ /// hub.
+ ///
+ ///
+ /// The reason closing the client connection.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> CloseAllConnectionsWithHttpMessagesAsync(string endpoint, string hub, string apiVersion, IList excluded = default(IList), string reason = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+
+ ///
+ /// Broadcast content inside request body to all the connected client
+ /// connections.
+ ///
+ ///
+ /// HTTP or HTTPS endpoint for the Web PubSub service instance.
+ ///
+ ///
+ /// Target hub name, which should start with alphabetic characters and
+ /// only contain alpha-numeric characters or underscore.
+ ///
+ ///
+ /// The version of the REST APIs.
+ ///
+ ///
+ /// The payload body.
+ ///
+ ///
+ /// Excluded connection Ids.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ Task> SendToAllWithHttpMessagesAsync(string endpoint, string hub, string apiVersion, string message, IList excluded = default(IList), Dictionary